bug 1155829 - add shutdown method to MaiAtkObject r=yzen
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Wed, 08 Apr 2015 11:14:42 -0400
changeset 259167 d8df74a22186fa016e22ed027ec83e76a5a594ee
parent 259166 7e3e8edde0a3e9dd06bd07214da6077b07cb8726
child 259168 a7a57e6ee03623c37b4f926c12c3fbdda34a93a6
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs1155829
milestone40.0a1
bug 1155829 - add shutdown method to MaiAtkObject r=yzen
accessible/atk/AccessibleWrap.cpp
--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -129,22 +129,39 @@ static const GInterfaceInfo atk_if_infos
 struct MaiAtkObject
 {
   AtkObject parent;
   /*
    * The AccessibleWrap whose properties and features are exported
    * via this object instance.
    */
   uintptr_t accWrap;
+
+  /*
+   * Shutdown this AtkObject.
+   */
+  void Shutdown();
 };
 
 // This is or'd with the pointer in MaiAtkObject::accWrap if the wrap-ee is a
 // proxy.
 static const uintptr_t IS_PROXY = 1;
 
+void
+MaiAtkObject::Shutdown()
+{
+  accWrap = 0;
+  MaiHyperlink* maiHyperlink =
+    (MaiHyperlink*)g_object_get_qdata(G_OBJECT(this), quark_mai_hyperlink);
+  if (maiHyperlink) {
+    delete maiHyperlink;
+    g_object_set_qdata(G_OBJECT(this), quark_mai_hyperlink, nullptr);
+  }
+}
+
 struct MaiAtkObjectClass
 {
     AtkObjectClass parent_class;
 };
 
 static guint mai_atk_object_signals [LAST_SIGNAL] = { 0, };
 
 static void MaybeFireNameChange(AtkObject* aAtkObj, const nsString& aNewName);
@@ -248,26 +265,19 @@ AccessibleWrap::~AccessibleWrap()
 }
 
 void
 AccessibleWrap::ShutdownAtkObject()
 {
   if (!mAtkObject)
     return;
 
-  if (IS_MAI_OBJECT(mAtkObject)) {
-    MAI_ATK_OBJECT(mAtkObject)->accWrap = 0;
-    MaiHyperlink* maiHyperlink
-      = (MaiHyperlink*)g_object_get_qdata(G_OBJECT(mAtkObject),
-                                          quark_mai_hyperlink);
-    if (maiHyperlink) {
-      delete maiHyperlink;
-      g_object_set_qdata(G_OBJECT(mAtkObject), quark_mai_hyperlink, nullptr);
-    }
-  }
+  MOZ_ASSERT(IS_MAI_OBJECT(mAtkObject));
+  if (IS_MAI_OBJECT(mAtkObject))
+    MAI_ATK_OBJECT(mAtkObject)->Shutdown();
 
   g_object_unref(mAtkObject);
   mAtkObject = nullptr;
 }
 
 void
 AccessibleWrap::Shutdown()
 {
@@ -1081,17 +1091,17 @@ a11y::ProxyCreated(ProxyAccessible* aPro
   obj->layer = ATK_LAYER_INVALID;
   aProxy->SetWrapper(reinterpret_cast<uintptr_t>(obj) | IS_PROXY);
 }
 
 void
 a11y::ProxyDestroyed(ProxyAccessible* aProxy)
 {
   auto obj = reinterpret_cast<MaiAtkObject*>(aProxy->GetWrapper() & ~IS_PROXY);
-  obj->accWrap = 0;
+  obj->Shutdown();
   g_object_unref(obj);
   aProxy->SetWrapper(0);
 }
 
 nsresult
 AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
 {
   nsresult rv = Accessible::HandleAccEvent(aEvent);