Bug 1124452 - Ensure the widget continues to be destroyed on the main thread. r=BenWa

This commit is contained in:
Kartikaya Gupta
2015-01-29 12:57:55 -05:00
parent d00963ed70
commit c536b29824
5 changed files with 24 additions and 0 deletions

View File

@@ -157,6 +157,7 @@ public:
int aArg = 0) {} int aArg = 0) {}
GeckoContentController() {} GeckoContentController() {}
virtual void Destroy() {}
protected: protected:
// Protected destructor, to discourage deletion outside of Release(): // Protected destructor, to discourage deletion outside of Release():

View File

@@ -83,3 +83,17 @@ ChromeProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aSc
{ {
APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
} }
void
ChromeProcessController::Destroy()
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::Destroy));
return;
}
MOZ_ASSERT(MessageLoop::current() == mUILoop);
mWidget = nullptr;
}

View File

@@ -27,6 +27,7 @@ class ChromeProcessController : public mozilla::layers::GeckoContentController
public: public:
explicit ChromeProcessController(nsIWidget* aWidget); explicit ChromeProcessController(nsIWidget* aWidget);
virtual void Destroy() MOZ_OVERRIDE;
// GeckoContentController interface // GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;

View File

@@ -88,6 +88,13 @@ CompositorParent::LayerTreeState::LayerTreeState()
{ {
} }
CompositorParent::LayerTreeState::~LayerTreeState()
{
if (mController) {
mController->Destroy();
}
}
typedef map<uint64_t, CompositorParent::LayerTreeState> LayerTreeMap; typedef map<uint64_t, CompositorParent::LayerTreeState> LayerTreeMap;
static LayerTreeMap sIndirectLayerTrees; static LayerTreeMap sIndirectLayerTrees;
static StaticAutoPtr<mozilla::Monitor> sIndirectLayerTreesLock; static StaticAutoPtr<mozilla::Monitor> sIndirectLayerTreesLock;

View File

@@ -291,6 +291,7 @@ public:
struct LayerTreeState { struct LayerTreeState {
LayerTreeState(); LayerTreeState();
~LayerTreeState();
nsRefPtr<Layer> mRoot; nsRefPtr<Layer> mRoot;
nsRefPtr<GeckoContentController> mController; nsRefPtr<GeckoContentController> mController;
CompositorParent* mParent; CompositorParent* mParent;