Qt: don't return dangling pointer

This commit is contained in:
李通洲 2020-01-05 10:57:09 +08:00
parent d9b6ab83cf
commit 039fba0344
No known key found for this signature in database
GPG Key ID: 185E60A519A7E290
2 changed files with 12 additions and 13 deletions

View File

@ -18,12 +18,12 @@
#include <string>
#include "Qt/QtHost.h"
const char* QtHost::SymbolMapFilename(std::string currentFilename) {
std::string result = currentFilename;
size_t dot = result.rfind('.');
if (dot == result.npos)
return (result + ".map").c_str();
std::string QtHost::SymbolMapFilename(std::string currentFilename) {
size_t dot = currentFilename.rfind('.');
if (dot == std::string::npos)
currentFilename.append(".map");
else
currentFilename.replace(dot, -1, ".map");
result.replace(dot, result.npos, ".map");
return result.c_str();
return currentFilename;
}

View File

@ -64,13 +64,12 @@ public:
#endif
}
virtual bool AttemptLoadSymbolMap() override {
return false;
// TODO: Make this work with Qt and threaded GL... not sure what's so broken.
// auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart);
// return g_symbolMap->LoadSymbolMap(fn);
auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart);
return g_symbolMap->LoadSymbolMap(fn.c_str());
}
void PrepareShutdown() {
g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart));
auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart);
g_symbolMap->SaveSymbolMap(fn.c_str());
}
void SetWindowTitle(const char *message) override {
std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION;
@ -91,6 +90,6 @@ public:
}
private:
const char* SymbolMapFilename(std::string currentFilename);
std::string SymbolMapFilename(std::string currentFilename);
MainWindow* mainWindow;
};