all repos — mgba @ a2ee0c20dcaf90e4fbb0443db94568db5cd48d7b

mGBA Game Boy Advance Emulator

Fix filename getting deleted early
Jeffrey Pfau jeffrey@endrift.com
Fri, 24 Oct 2014 02:23:37 -0700
commit

a2ee0c20dcaf90e4fbb0443db94568db5cd48d7b

parent

397ddafdd20115dfa3257fad3f343f5a132a24d4

1 files changed, 5 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -140,7 +140,7 @@

m_threadContext.sync.videoFrameWait = m_videoSync; m_threadContext.sync.audioWait = m_audioSync; - m_threadContext.fname = m_fname.toLocal8Bit().constData(); + m_threadContext.fname = strdup(m_fname.toLocal8Bit().constData()); if (m_dirmode) { m_threadContext.gameDir = VDirOpen(m_threadContext.fname); m_threadContext.stateDir = m_threadContext.gameDir;

@@ -186,6 +186,10 @@ return;

} GBAThreadEnd(&m_threadContext); GBAThreadJoin(&m_threadContext); + if (m_threadContext.fname) { + free(const_cast<char*>(m_threadContext.fname)); + m_threadContext.fname = nullptr; + } m_gameOpen = false; emit gameStopped(&m_threadContext);