From a60a16c86054374910166f0a8a22e14917645764 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Wed, 25 Jun 2003 06:29:44 +0000 Subject: [PATCH] Fix a shutdown crash with gtk2 by not attempting to unload libgconf after we've called gconf_client_get_default(). gconf initializes ORBit which in turn registers atexit() handlers, so unloading the library would cause those function pointers to become invalid. Also, release our reference to the GConfClient in the GConfProxy dtor, and remove some unneeded code from the dtor. Bug 210471, r=bolian.yin@sun.com, sr=alecf. git-svn-id: svn://10.0.0.236/trunk@144138 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/gconf/nsSystemPrefService.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp b/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp index 1d3f548ac54..76fdc7a142c 100644 --- a/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp +++ b/mozilla/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp @@ -40,6 +40,7 @@ * ***** END LICENSE BLOCK ***** */ #include +#include #include "plstr.h" #include "nsCOMPtr.h" @@ -588,16 +589,12 @@ GConfProxy::GConfProxy(nsSystemPrefService *aSysPrefService): GConfProxy::~GConfProxy() { - mInitialized = PR_FALSE; + if (mGConfClient) + g_object_unref(G_OBJECT(mGConfClient)); - if (mGConfLib) { - PR_UnloadLibrary(mGConfLib); - mGConfLib = nsnull; - } if (mObservers) { (void)mObservers->EnumerateForwards(gconfDeleteObserver, nsnull); delete mObservers; - mObservers = nsnull; } } @@ -644,7 +641,7 @@ GConfProxy::Init() func = PR_FindFunctionSymbol(mGConfLib, funcList->FuncName); if (!func) { SYSPREF_LOG(("Check GConf Func Error: %s", funcList->FuncName)); - goto init_failed; + goto init_failed_unload; } funcList->FuncPtr = func; } @@ -652,6 +649,10 @@ GConfProxy::Init() InitFuncPtrs(); mGConfClient = GConfClientGetDefault(); + + // Don't unload past this point, since GConf's initialization of ORBit + // causes atexit handlers to be registered. + if (!mGConfClient) { SYSPREF_LOG(("Fail to Get default gconf client\n")); goto init_failed; @@ -659,8 +660,9 @@ GConfProxy::Init() mInitialized = PR_TRUE; return PR_TRUE; - init_failed: + init_failed_unload: PR_UnloadLibrary(mGConfLib); + init_failed: mGConfLib = nsnull; return PR_FALSE; }