Bug 660131 - Call g_type_init in loadProc of kGnomeModule to fix crash on mochitest-plain ; r=karlt
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 01 Jun 2011 13:19:16 -0400
changeset 70728 d6a897278194dc9f98d92362f7408d28f78f8cd9
parent 70727 a10e7738004dd077f4cc60bf8d917dc69dbdd1d7
child 70729 66efdc6a98c5811fb771f15f11ef8afe54a04d07
push id209
push userbzbarsky@mozilla.com
push dateTue, 05 Jul 2011 17:42:16 +0000
treeherdermozilla-aurora@cc6e30cce8af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs660131
milestone7.0a1
Bug 660131 - Call g_type_init in loadProc of kGnomeModule to fix crash on mochitest-plain ; r=karlt
toolkit/system/gnome/nsGConfService.cpp
toolkit/system/gnome/nsGIOService.cpp
toolkit/system/gnome/nsGIOService.h
toolkit/system/gnome/nsGnomeModule.cpp
--- a/toolkit/system/gnome/nsGConfService.cpp
+++ b/toolkit/system/gnome/nsGConfService.cpp
@@ -49,17 +49,16 @@ nsGConfService::~nsGConfService()
 {
   if (mClient)
     g_object_unref(mClient);
 }
 
 nsresult
 nsGConfService::Init()
 {
-  g_type_init();
   mClient = gconf_client_get_default();
   return mClient ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMPL_ISUPPORTS1(nsGConfService, nsIGConfService)
 
 NS_IMETHODIMP
 nsGConfService::GetBool(const nsACString &aKey, PRBool *aResult)
--- a/toolkit/system/gnome/nsGIOService.cpp
+++ b/toolkit/system/gnome/nsGIOService.cpp
@@ -294,23 +294,16 @@ nsGIOMimeApp::SetAsDefaultForURIScheme(n
               error->message);
     g_error_free(error);
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
-nsresult
-nsGIOService::Init()
-{
-  // do nothing, gvfs/gio does not init.
-  return NS_OK;
-}
-
 NS_IMPL_ISUPPORTS1(nsGIOService, nsIGIOService)
 
 NS_IMETHODIMP
 nsGIOService::GetMimeTypeFromExtension(const nsACString& aExtension,
                                              nsACString& aMimeType)
 {
   nsCAutoString fileExtToUse("file.");
   fileExtToUse.Append(aExtension);
--- a/toolkit/system/gnome/nsGIOService.h
+++ b/toolkit/system/gnome/nsGIOService.h
@@ -44,14 +44,12 @@
 #define NS_GIOSERVICE_CID \
 {0xe3a1f3c9, 0x3ae1, 0x4b40, {0xa5, 0xe0, 0x7b, 0x45, 0x7f, 0xc9, 0xa9, 0xad}}
 
 class nsGIOService : public nsIGIOService
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIGIOSERVICE
-
-  NS_HIDDEN_(nsresult) Init();
 };
 
 #endif
 
--- a/toolkit/system/gnome/nsGnomeModule.cpp
+++ b/toolkit/system/gnome/nsGnomeModule.cpp
@@ -45,17 +45,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGC
 #endif
 #ifdef MOZ_ENABLE_GNOMEVFS
 #include "nsGnomeVFSService.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGnomeVFSService, Init)
 #endif
 #ifdef MOZ_ENABLE_GIO
 #include "nsGIOService.h"
 #include "nsGSettingsService.h"
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGIOService, Init)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsGIOService)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGSettingsService, Init)
 #endif
 #ifdef MOZ_ENABLE_LIBNOTIFY
 #include "nsAlertsService.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAlertsService, Init)
 #endif
 
 #ifdef MOZ_ENABLE_GCONF
@@ -102,15 +102,25 @@ static const mozilla::Module::ContractID
   { NS_GSETTINGSSERVICE_CONTRACTID, &kNS_GSETTINGSSERVICE_CID },
 #endif
 #ifdef MOZ_ENABLE_LIBNOTIFY
   { NS_SYSTEMALERTSERVICE_CONTRACTID, &kNS_SYSTEMALERTSSERVICE_CID },
 #endif
   { NULL }
 };
 
+static nsresult
+InitGType ()
+{
+  g_type_init();
+  return NS_OK;
+}
+
 static const mozilla::Module kGnomeModule = {
   mozilla::Module::kVersion,
   kGnomeCIDs,
-  kGnomeContracts
+  kGnomeContracts,
+  NULL,
+  NULL,
+  InitGType
 };
 
 NSMODULE_DEFN(mozgnome) = &kGnomeModule;