Fix crash in profile migrator on startup if there are no phoenix profiles - linux and mac

This commit is contained in:
ben%bengoodger.com 2004-03-09 21:16:02 +00:00
Родитель 778e2e29fa
Коммит 90bc2f6eec
1 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -68,11 +68,13 @@ nsProfileMigrator::Migrate()
&needsActiveProfile); &needsActiveProfile);
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (!needsActiveProfile) if (mMigrator && mSourceKey) {
rv = OpenMigrationWizard(); if (!needsActiveProfile)
else { rv = OpenMigrationWizard();
nsCOMPtr<nsIObserverService> obs(do_GetService("@mozilla.org/observer-service;1")); else {
rv = obs->AddObserver(this, "browser-window-before-show", PR_FALSE); nsCOMPtr<nsIObserverService> obs(do_GetService("@mozilla.org/observer-service;1"));
rv = obs->AddObserver(this, "browser-window-before-show", PR_FALSE);
}
} }
return rv; return rv;
} }
@ -151,7 +153,7 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMig
*aMigrator = nsnull; *aMigrator = nsnull;
*aKey = nsnull; *aKey = nsnull;
#ifdef XP_WIN #if XP_WIN
HKEY hkey; HKEY hkey;
const char* kCommandKey = "SOFTWARE\\Classes\\HTTP\\shell\\open\\command"; const char* kCommandKey = "SOFTWARE\\Classes\\HTTP\\shell\\open\\command";
@ -252,11 +254,19 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMig
} }
#else #else
// XXXben - until we figure out what to do here with default browsers on MacOS and // XXXben - until we figure out what to do here with default browsers on MacOS and
// GNOME, simply copy data from a previous Phoenix install. // GNOME, simply copy data from a previous Phoenix or Seamonkey install.
*aNeedsActiveProfile = PR_FALSE; *aNeedsActiveProfile = PR_FALSE;
nsCOMPtr<nsISupportsString> key(do_CreateInstance("@mozilla.org/supports-string;1")); nsCOMPtr<nsISupportsString> key(do_CreateInstance("@mozilla.org/supports-string;1"));
key->SetData(NS_LITERAL_STRING("phoenix")); key->SetData(NS_LITERAL_STRING("phoenix"));
nsCOMPtr<nsIBrowserProfileMigrator> bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix"); nsCOMPtr<nsIBrowserProfileMigrator> bpm(do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix"));
PRBool exists;
bpm->GetSourceExists(&exists);
if (!exists) {
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey");
bpm->GetSourceExists(&exists);
if (!exists)
bpm = nsnull;
}
NS_IF_ADDREF(*aKey = key); NS_IF_ADDREF(*aKey = key);
NS_IF_ADDREF(*aMigrator = bpm); NS_IF_ADDREF(*aMigrator = bpm);