diff --git a/src/solvespace.cpp b/src/solvespace.cpp index a8d1a15..ee30dbd 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -125,12 +125,8 @@ void SolveSpaceUI::Init() { SetLocale(locale); } - generateAllTimer = Platform::CreateTimer(); - generateAllTimer->onTimeout = std::bind(&SolveSpaceUI::GenerateAll, &SS, Generate::DIRTY, - /*andFindFree=*/false, /*genForBBox=*/false); - - showTWTimer = Platform::CreateTimer(); - showTWTimer->onTimeout = std::bind(&TextWindow::Show, &TW); + refreshTimer = Platform::CreateTimer(); + refreshTimer->onTimeout = std::bind(&SolveSpaceUI::Refresh, &SS); autosaveTimer = Platform::CreateTimer(); autosaveTimer->onTimeout = std::bind(&SolveSpaceUI::Autosave, &SS); @@ -302,12 +298,26 @@ void SolveSpaceUI::Exit() { Platform::ExitGui(); } +void SolveSpaceUI::Refresh() { + // generateAll must happen bfore updating displays + if(scheduledGenerateAll) { + GenerateAll(Generate::DIRTY, /*andFindFree=*/false, /*genForBBox=*/false); + scheduledGenerateAll = false; + } + if(scheduledShowTW) { + TW.Show(); + scheduledShowTW = false; + } +} + void SolveSpaceUI::ScheduleGenerateAll() { - generateAllTimer->RunAfterProcessingEvents(); + scheduledGenerateAll = true; + refreshTimer->RunAfterProcessingEvents(); } void SolveSpaceUI::ScheduleShowTW() { - showTWTimer->RunAfterProcessingEvents(); + scheduledShowTW = true; + refreshTimer->RunAfterProcessingEvents(); } void SolveSpaceUI::ScheduleAutosave() { diff --git a/src/solvespace.h b/src/solvespace.h index 1c22db6..fbae19e 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -793,9 +793,11 @@ public: // the sketch! bool allConsistent; - Platform::TimerRef showTWTimer; - Platform::TimerRef generateAllTimer; + bool scheduledGenerateAll; + bool scheduledShowTW; + Platform::TimerRef refreshTimer; Platform::TimerRef autosaveTimer; + void Refresh(); void ScheduleShowTW(); void ScheduleGenerateAll(); void ScheduleAutosave();