Bug 1222092. Don't let sFocusedIMEWidget keep an nsIWidget alive during shutdown. r=masayuki

This commit is contained in:
Robert O'Callahan 2015-11-13 17:05:54 +13:00
parent f5c152dfb5
commit a8cbc64f94
3 changed files with 20 additions and 3 deletions

View File

@ -162,7 +162,7 @@ GetNotifyIMEMessageName(IMEMessage aMessage)
StaticRefPtr<nsIContent> IMEStateManager::sContent;
nsPresContext* IMEStateManager::sPresContext = nullptr;
StaticRefPtr<nsIWidget> IMEStateManager::sFocusedIMEWidget;
nsIWidget* IMEStateManager::sFocusedIMEWidget;
StaticRefPtr<TabParent> IMEStateManager::sActiveTabParent;
StaticRefPtr<IMEContentObserver> IMEStateManager::sActiveIMEContentObserver;
TextCompositionArray* IMEStateManager::sTextCompositions = nullptr;
@ -217,6 +217,15 @@ IMEStateManager::OnTabParentDestroying(TabParent* aTabParent)
// disable IME.
}
// static
void
IMEStateManager::WidgetDestroyed(nsIWidget* aWidget)
{
if (sFocusedIMEWidget == aWidget) {
sFocusedIMEWidget = nullptr;
}
}
// static
void
IMEStateManager::StopIMEStateManagement()
@ -1316,7 +1325,7 @@ IMEStateManager::NotifyIME(const IMENotification& aNotification,
"aWidget=0x%p, aOriginIsRemote=%s), sFocusedIMEWidget=0x%p, "
"sRemoteHasFocus=%s",
GetNotifyIMEMessageName(aNotification.mMessage), aWidget,
GetBoolName(aOriginIsRemote), sFocusedIMEWidget.get(),
GetBoolName(aOriginIsRemote), sFocusedIMEWidget,
GetBoolName(sRemoteHasFocus)));
if (NS_WARN_IF(!aWidget)) {

View File

@ -64,6 +64,11 @@ public:
*/
static void OnTabParentDestroying(TabParent* aTabParent);
/**
* Called when aWidget is being deleted.
*/
static void WidgetDestroyed(nsIWidget* aWidget);
/**
* SetIMEContextForChildProcess() is called when aTabParent receives
* SetInputContext() from the remote process.
@ -225,7 +230,7 @@ protected:
static StaticRefPtr<nsIContent> sContent;
static nsPresContext* sPresContext;
static StaticRefPtr<nsIWidget> sFocusedIMEWidget;
static nsIWidget* sFocusedIMEWidget;
static StaticRefPtr<TabParent> sActiveTabParent;
// sActiveIMEContentObserver points to the currently active
// IMEContentObserver. This is null if there is no focused editor.

View File

@ -44,6 +44,7 @@
#include "mozilla/MouseEvents.h"
#include "GLConsts.h"
#include "mozilla/unused.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/VsyncDispatcher.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/APZEventState.h"
@ -282,6 +283,8 @@ nsBaseWidget::FreeShutdownObserver()
//-------------------------------------------------------------------------
nsBaseWidget::~nsBaseWidget()
{
IMEStateManager::WidgetDestroyed(this);
if (mLayerManager &&
mLayerManager->GetBackendType() == LayersBackend::LAYERS_BASIC) {
static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();