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

View File

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