StdScheduler: Make DoScheduleProcs virtual, override it in C4AbstractApp and set isInManualLoop flag around the DoScheduleProcs call so the FlushMessages() of C4AbstractApp will happen when isInManualLoop is true

stable-5.4
Martin Plicht 2014-02-16 14:48:16 +01:00
parent 75f3fb2d70
commit 92186db246
4 changed files with 8 additions and 9 deletions

View File

@ -25,7 +25,7 @@ void C4AbstractApp::Run()
ScheduleProcs();
}
bool C4AbstractApp::ScheduleProcs(int iTimeout)
bool C4AbstractApp::DoScheduleProcs(int iTimeout)
{
// Always fail after quit message
if(fQuitMsgReceived)
@ -34,7 +34,7 @@ bool C4AbstractApp::ScheduleProcs(int iTimeout)
// Unfortunately, the SDL event loop needs to be polled
FlushMessages();
#endif
return StdScheduler::ScheduleProcs(iTimeout);
return StdScheduler::DoScheduleProcs(iTimeout);
}
void C4Window::PerformUpdate()

View File

@ -97,7 +97,7 @@ public:
// Gamma
virtual bool ApplyGammaRamp(struct _GAMMARAMP &ramp, bool fForce);
virtual bool SaveDefaultGammaRamp(struct _GAMMARAMP &ramp);
virtual bool ScheduleProcs(int iTimeout = 1000/36);
virtual bool DoScheduleProcs(int iTimeout);
bool FlushMessages();
C4Window * pWindow;
bool fQuitMsgReceived; // if true, a quit message has been received and the application should terminate

View File

@ -132,7 +132,6 @@ C4TimeMilliseconds StdSchedulerProc::GetNextTick(C4TimeMilliseconds tNow)
bool StdScheduler::ScheduleProcs(int iTimeout)
{
isInManualLoop = true;
// Needs at least one process to work properly
if (!procs.size()) return false;
@ -149,8 +148,10 @@ bool StdScheduler::ScheduleProcs(int iTimeout)
}
}
bool old = isInManualLoop;
isInManualLoop = true;
bool res = DoScheduleProcs(iTimeout);
isInManualLoop = false;
isInManualLoop = old;
return res;
}

View File

@ -246,15 +246,13 @@ public:
// needs to be called on thread tasks for this scheduler are meant to be run on
void StartOnCurrentThread();
virtual bool ScheduleProcs(int iTimeout = -1);
bool ScheduleProcs(int iTimeout = 1000/36);
void UnBlock();
protected:
// overridable
virtual void OnError(StdSchedulerProc *) { }
private:
bool DoScheduleProcs(int iTimeout);
virtual bool DoScheduleProcs(int iTimeout);
};
// A simple process scheduler thread