mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1054819 - Ensure that the dictionary is released on the main thread. r=ehsan
CLOSED TREE
This commit is contained in:
parent
9dd31134f4
commit
37a95fbda8
@ -18,6 +18,7 @@
|
||||
#include "nsUnicharInputStream.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
#define MOZ_PERSONAL_DICT_NAME "persdict.dat"
|
||||
|
||||
@ -54,11 +55,18 @@ public:
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
mDict->SyncLoad();
|
||||
mDict->SyncLoad();
|
||||
|
||||
// Release refptr on the mainthread
|
||||
NS_DispatchToMainThread(this);
|
||||
// Release the dictionary on the main thread
|
||||
mozPersonalDictionary *dict;
|
||||
mDict.forget(&dict);
|
||||
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
if (mainThread) {
|
||||
NS_ProxyRelease(mainThread, static_cast<mozIPersonalDictionary *>(dict));
|
||||
} else {
|
||||
// It's better to leak the dictionary than to release it on a wrong thread
|
||||
NS_WARNING("Cannot get main thread, leaking mozPersonalDictionary.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user