--- a/embedding/browser/qt/src/qgeckoglobals.cpp
+++ b/embedding/browser/qt/src/qgeckoglobals.cpp
@@ -162,80 +162,78 @@ int QGeckoGlobals::sNumAppComps = size
void
QGeckoGlobals::pushStartup()
{
// increment the number of widgets
sWidgetCount++;
// if this is the first widget, fire up xpcom
- if (sWidgetCount == 1) {
- nsresult rv;
- nsCOMPtr<nsILocalFile> binDir;
-
- if (sCompPath) {
- rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
- if (NS_FAILED(rv))
- return;
- }
+ if (sWidgetCount != 1) return;
+ nsresult rv;
+ nsCOMPtr<nsILocalFile> binDir;
- const char *grePath = sPath;
-
- if (!grePath)
- grePath = getenv("MOZILLA_FIVE_HOME");
-
- if (!grePath)
- return;
-
- nsCOMPtr<nsILocalFile> greDir;
- rv = NS_NewNativeLocalFile(nsDependentCString(grePath), PR_TRUE,
- getter_AddRefs(greDir));
+ if (sCompPath) {
+ rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
if (NS_FAILED(rv))
return;
+ }
- if (sProfileDir && !sProfileLock) {
- rv = XRE_LockProfileDirectory(sProfileDir,
- &sProfileLock);
- if (NS_FAILED(rv)) return;
- }
+ const char *grePath = sPath;
+
+ if (!grePath)
+ grePath = getenv("MOZILLA_FIVE_HOME");
+
+ if (!grePath)
+ return;
+
+ nsCOMPtr<nsILocalFile> greDir;
+ rv = NS_NewNativeLocalFile(nsDependentCString(grePath), PR_TRUE,
+ getter_AddRefs(greDir));
+ if (NS_FAILED(rv))
+ return;
- rv = XRE_InitEmbedding(greDir, binDir,
- const_cast<QTEmbedDirectoryProvider*>
- (&kDirectoryProvider),
- nsnull, nsnull);
+ if (sProfileDir && !sProfileLock) {
+ rv = XRE_LockProfileDirectory(sProfileDir,
+ &sProfileLock);
+ if (NS_FAILED(rv)) return;
+ }
- if (NS_FAILED(rv))
- return;
+ rv = XRE_InitEmbedding(greDir, binDir,
+ const_cast<QTEmbedDirectoryProvider*>
+ (&kDirectoryProvider),
+ nsnull, nsnull);
- if (sProfileDir)
- XRE_NotifyProfile();
+ if (NS_FAILED(rv))
+ return;
- rv = registerAppComponents();
- NS_ASSERTION(NS_SUCCEEDED(rv), "Warning: Failed to register app components.\n");
- }
+ if (sProfileDir)
+ XRE_NotifyProfile();
+
+ rv = registerAppComponents();
+ NS_ASSERTION(NS_SUCCEEDED(rv), "Warning: Failed to register app components.\n");
}
void
QGeckoGlobals::popStartup()
{
sWidgetCount--;
- if (sWidgetCount == 0) {
+ if (sWidgetCount != 0) return;
- // we no longer need a reference to the DirectoryServiceProvider
- if (sAppFileLocProvider) {
- NS_RELEASE(sAppFileLocProvider);
- sAppFileLocProvider = nsnull;
- }
+ // we no longer need a reference to the DirectoryServiceProvider
+ if (sAppFileLocProvider) {
+ NS_RELEASE(sAppFileLocProvider);
+ sAppFileLocProvider = nsnull;
+ }
- // shut down XPCOM/Embedding
- XRE_TermEmbedding();
+ // shut down XPCOM/Embedding
+ XRE_TermEmbedding();
- NS_IF_RELEASE(sProfileLock);
- NS_IF_RELEASE(sProfileDir);
- }
+ NS_IF_RELEASE(sProfileLock);
+ NS_IF_RELEASE(sProfileDir);
}
void
QGeckoGlobals::setPath(const char *aPath)
{
if (sPath)
free(sPath);
if (aPath)