mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 905405. Wrap mLastNativeEventScheduled in a mutex to avoid racing on it. r=bsmedberg
This commit is contained in:
parent
294cedd09d
commit
729180d69e
@ -161,9 +161,12 @@ nsAppShell::ScheduleNativeEventCallback()
|
||||
{
|
||||
// Post a message to the hidden message window
|
||||
NS_ADDREF_THIS(); // will be released when the event is processed
|
||||
// Time stamp this event so we can detect cases where the event gets
|
||||
// dropping in sub classes / modal loops we do not control.
|
||||
mLastNativeEventScheduled = TimeStamp::NowLoRes();
|
||||
{
|
||||
MutexAutoLock lock(mLastNativeEventScheduledMutex);
|
||||
// Time stamp this event so we can detect cases where the event gets
|
||||
// dropping in sub classes / modal loops we do not control.
|
||||
mLastNativeEventScheduled = TimeStamp::NowLoRes();
|
||||
}
|
||||
::PostMessage(mEventWnd, sAppShellGeckoMsgId, 0, reinterpret_cast<LPARAM>(this));
|
||||
}
|
||||
|
||||
@ -238,8 +241,13 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
static const mozilla::TimeDuration nativeEventStarvationLimit =
|
||||
mozilla::TimeDuration::FromSeconds(NATIVE_EVENT_STARVATION_LIMIT);
|
||||
|
||||
if ((TimeStamp::NowLoRes() - mLastNativeEventScheduled) >
|
||||
nativeEventStarvationLimit) {
|
||||
TimeDuration timeSinceLastNativeEventScheduled;
|
||||
{
|
||||
MutexAutoLock lock(mLastNativeEventScheduledMutex);
|
||||
timeSinceLastNativeEventScheduled =
|
||||
TimeStamp::NowLoRes() - mLastNativeEventScheduled;
|
||||
}
|
||||
if (timeSinceLastNativeEventScheduled > nativeEventStarvationLimit) {
|
||||
ScheduleNativeEventCallback();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsBaseAppShell.h"
|
||||
#include <windows.h>
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
|
||||
// The maximum time we allow before forcing a native event callback.
|
||||
// In seconds.
|
||||
@ -22,7 +23,8 @@ class nsAppShell : public nsBaseAppShell
|
||||
public:
|
||||
nsAppShell() :
|
||||
mEventWnd(NULL),
|
||||
mNativeCallbackPending(false)
|
||||
mNativeCallbackPending(false),
|
||||
mLastNativeEventScheduledMutex("nsAppShell::mLastNativeEventScheduledMutex")
|
||||
{}
|
||||
typedef mozilla::TimeStamp TimeStamp;
|
||||
|
||||
@ -43,6 +45,8 @@ protected:
|
||||
protected:
|
||||
HWND mEventWnd;
|
||||
bool mNativeCallbackPending;
|
||||
|
||||
Mutex mLastNativeEventScheduledMutex;
|
||||
TimeStamp mLastNativeEventScheduled;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user