From 6289fa5a0208dee507bd5ac825aee31708373241 Mon Sep 17 00:00:00 2001 From: romashin Date: Sat, 19 Apr 2008 18:37:06 +0300 Subject: [PATCH] Fixed bug https://bugzilla.mozilla.org/show_bug.cgi?id=408490 --- embedding/browser/qt/src/qgeckoglobals.cpp | 43 ++++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/embedding/browser/qt/src/qgeckoglobals.cpp b/embedding/browser/qt/src/qgeckoglobals.cpp index be5310e7cd7..cb6d2682700 100644 --- a/embedding/browser/qt/src/qgeckoglobals.cpp +++ b/embedding/browser/qt/src/qgeckoglobals.cpp @@ -188,6 +188,12 @@ QGeckoGlobals::pushStartup() if (NS_FAILED(rv)) return; + if (sProfileDir && !sProfileLock) { + rv = XRE_LockProfileDirectory(sProfileDir, + &sProfileLock); + if (NS_FAILED(rv)) return; + } + rv = XRE_InitEmbedding(greDir, binDir, const_cast (&kDirectoryProvider), @@ -196,12 +202,6 @@ QGeckoGlobals::pushStartup() if (NS_FAILED(rv)) return; - // we no longer need a reference to the DirectoryServiceProvider - if (sAppFileLocProvider) { - NS_RELEASE(sAppFileLocProvider); - sAppFileLocProvider = nsnull; - } - if (sProfileDir) XRE_NotifyProfile(); @@ -215,8 +215,18 @@ QGeckoGlobals::popStartup() { sWidgetCount--; if (sWidgetCount == 0) { + + // we no longer need a reference to the DirectoryServiceProvider + if (sAppFileLocProvider) { + NS_RELEASE(sAppFileLocProvider); + sAppFileLocProvider = nsnull; + } + // shut down XPCOM/Embedding XRE_TermEmbedding(); + + NS_IF_RELEASE(sProfileLock); + NS_IF_RELEASE(sProfileDir); } } @@ -264,16 +274,27 @@ QGeckoGlobals::setProfilePath(const char *aDir, const char *aName) nsresult rv = NS_NewNativeLocalFile(nsDependentCString(aDir), PR_TRUE, &sProfileDir); + + if (NS_SUCCEEDED(rv) && aName) + rv = sProfileDir->AppendNative(nsDependentCString(aName)); + if (NS_SUCCEEDED(rv)) { + PRBool exists = PR_FALSE; + rv = sProfileDir->Exists(&exists); + if (!exists) + rv = sProfileDir->Create(nsIFile::DIRECTORY_TYPE, 0700); rv = XRE_LockProfileDirectory(sProfileDir, &sProfileLock); - if (NS_SUCCEEDED(rv)) { - if (sWidgetCount) - XRE_NotifyProfile(); - return; - } + } + + if (NS_SUCCEEDED(rv)) { + if (sWidgetCount) + XRE_NotifyProfile(); + + return; } NS_WARNING("Failed to lock profile."); + // Failed NS_IF_RELEASE(sProfileDir); NS_IF_RELEASE(sProfileLock);