From b0a28d346eb9ab9d7914749decae83eaf1412d78 Mon Sep 17 00:00:00 2001 From: "rpotts%netscape.com" Date: Tue, 16 Mar 1999 07:15:37 +0000 Subject: [PATCH] fix for bug #2343 - Preferences are not initialized in the apprunner... --- xpfe/bootstrap/makefile.win | 1 + xpfe/bootstrap/nsAppRunner.cpp | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/xpfe/bootstrap/makefile.win b/xpfe/bootstrap/makefile.win index e40620fedbf..b67920e8d4e 100644 --- a/xpfe/bootstrap/makefile.win +++ b/xpfe/bootstrap/makefile.win @@ -38,6 +38,7 @@ LINCS=-I$(PUBLIC)\raptor \ -I$(PUBLIC)\pref \ -I$(PUBLIC)\js \ -I$(PUBLIC)\dom \ + -I$(PUBLIC)\pref \ -I$(PUBLIC)\rdf \ -I$(PUBLIC)\editor \ -I$(PUBLIC)\caps \ diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 1abdbf7b409..da4bd1914ac 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -20,6 +20,7 @@ #include "nsIComponentManager.h" #include "nsIURL.h" #include "nsIWidget.h" +#include "nsIPref.h" #include "plevent.h" #include "nsIAppShell.h" @@ -37,12 +38,13 @@ static struct MacInitializer { MacInitializer() { InitializeMacToolbox(); } } gI #endif // XP_MAC /* Define Class IDs */ -static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); -static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); +static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); +static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); /* Define Interface IDs */ -static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID); -static NS_DEFINE_IID(kICmdLineServiceIID, NS_ICOMMANDLINE_SERVICE_IID); +static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID); +static NS_DEFINE_IID(kICmdLineServiceIID, NS_ICOMMANDLINE_SERVICE_IID); /********************************************* AppCores @@ -98,12 +100,14 @@ int main(int argc, char* argv[]) nsIAppShellService* appShell; nsIDOMAppCoresManager *appCoresManager; nsIURL* url; + nsIPref *prefs; /* * initialize all variables that are NS_IF_RELEASE(...) during * cleanup... */ url = nsnull; + prefs = nsnull; appShell = nsnull; cmdLineArgs = nsnull; appCoresManager = nsnull; @@ -119,6 +123,17 @@ int main(int argc, char* argv[]) // XXX: This call will be replaced by a registry initialization... NS_SetupRegistry_1(); + /* + * Load preferences + */ + rv = nsServiceManager::GetService(kPrefCID, + nsIPref::GetIID(), + (nsISupports **)&prefs); + if (NS_FAILED(rv)) { + goto done; + } + prefs->Startup("prefs.js"); + /* * Start up the core services: * - Command-line processor. @@ -358,6 +373,12 @@ done: nsServiceManager::ReleaseService(kAppCoresManagerCID, appCoresManager); } + /* Release the global preferences... */ + if (prefs) { + prefs->Shutdown(); + nsServiceManager::ReleaseService(kPrefCID, prefs); + } + /* * Translate the nsresult into an appropriate platform-specific return code. */