Bug fix for Qt TAS editor, don't call updateCaption from within emulation thread. Instead, set a flag to notify GUI thread to update caption.

This commit is contained in:
mjbudd77 2021-12-07 06:40:22 -05:00
parent 53463bc370
commit f6b52262da
4 changed files with 16 additions and 2 deletions

View File

@ -599,7 +599,7 @@ void GREENZONE::invalidate(int after)
} }
// redraw Piano Roll even if Greenzone didn't change // redraw Piano Roll even if Greenzone didn't change
//pianoRoll.redraw(); //pianoRoll.redraw();
bookmarks->redrawBookmarksList(); //bookmarks->redrawBookmarksList();
} }
// invalidate and restore playback // invalidate and restore playback
void GREENZONE::invalidateAndUpdatePlayback(int after) void GREENZONE::invalidateAndUpdatePlayback(int after)

View File

@ -260,6 +260,9 @@ void RECORDER::recheckRecordingRadioButtons()
} }
} }
// The recordInput function can be called from the emulation thread, it is important that it does not
// attempt to alter the state of any Qt widgets from within itself or any functions that it calls (directly and indirectly).
// Changing Qt widgets outside of the GUI thread may cause crashes.
void RECORDER::recordInput(void) void RECORDER::recordInput(void)
{ {
bool changes_made = false; bool changes_made = false;

View File

@ -58,6 +58,7 @@ void TASEDITOR_PROJECT::init()
void TASEDITOR_PROJECT::reset() void TASEDITOR_PROJECT::reset()
{ {
changed = false; changed = false;
updateCaptionFlag = false;
} }
void TASEDITOR_PROJECT::update() void TASEDITOR_PROJECT::update()
{ {
@ -75,6 +76,12 @@ void TASEDITOR_PROJECT::update()
// in case user pressed Cancel, postpone saving to next time // in case user pressed Cancel, postpone saving to next time
sheduleNextAutosave(); sheduleNextAutosave();
} }
if ( updateCaptionFlag )
{
updateCaptionFlag = false;
tasWin->updateCaption();
}
} }
bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool saveMarkers, bool saveBookmarks, int saveGreenzone, bool saveHistory, bool savePianoRoll, bool saveSelection) bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool saveMarkers, bool saveBookmarks, int saveGreenzone, bool saveHistory, bool savePianoRoll, bool saveSelection)
@ -381,8 +388,11 @@ void TASEDITOR_PROJECT::setProjectChanged()
{ {
if (!changed) if (!changed)
{ {
// set updateCaptionFlag to ensure that the window caption is only
// updated in the GUI thread. Updating the GUI in the emulation thread
// may cause crashes.
changed = true; changed = true;
tasWin->updateCaption(); updateCaptionFlag = true;
sheduleNextAutosave(); sheduleNextAutosave();
} }
} }

View File

@ -69,6 +69,7 @@ public:
private: private:
bool changed; bool changed;
bool updateCaptionFlag;
int nextSaveShedule; int nextSaveShedule;
std::string projectFile; // full path std::string projectFile; // full path