Bug 564770 - provide graphics system parameter for child processes. r=dougt
authorOleg Romashin <romaxa@gmail.com>
Mon, 24 May 2010 14:21:52 +0200
changeset 42607 b39ebd4f4fcd4096f4cbd11b21960c9109a5f1c5
parent 42606 cc99e3e9efb4ae36127416d403c1aa678443056f
child 42608 1c678a46604fafb1ead11016a2b1b944dadc4d9b
push idunknown
push userunknown
push dateunknown
reviewersdougt
bugs564770
milestone1.9.3a5pre
Bug 564770 - provide graphics system parameter for child processes. r=dougt
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsQAppInstance.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3109,16 +3109,20 @@ XRE_main(int argc, char* argv[], const n
     const char* desktopStartupIDEnv = PR_GetEnv("DESKTOP_STARTUP_ID");
     nsCAutoString desktopStartupID;
     if (desktopStartupIDEnv) {
       desktopStartupID.Assign(desktopStartupIDEnv);
     }
 #endif
 
 #if defined(MOZ_WIDGET_QT)
+    const char* qgraphicssystemARG = NULL;
+    ar = CheckArg("graphicssystem", PR_TRUE, &qgraphicssystemARG);
+    if (ar == ARG_FOUND)
+      PR_SetEnv(PR_smprintf("MOZ_QT_GRAPHICSSYSTEM=%s", qgraphicssystemARG));
     QApplication app(gArgc, gArgv);
 #endif
 #if defined(MOZ_WIDGET_GTK2)
 #ifdef MOZ_MEMORY
     // Disable the slice allocator, since jemalloc already uses similar layout
     // algorithms, and using a sub-allocator tends to increase fragmentation.
     // This must be done before g_thread_init() is called.
     g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, 1);
--- a/toolkit/xre/nsQAppInstance.cpp
+++ b/toolkit/xre/nsQAppInstance.cpp
@@ -33,33 +33,38 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsQAppInstance.h"
 #include <QApplication>
+#include "prenv.h"
 
 // declared in nsAppRunner.cpp
 extern int    gArgc;
 extern char **gArgv;
 
 nsQAppInstance *nsQAppInstance::sQAppInstance = NULL;
 int nsQAppInstance::sQAppRefCount = 0;
 
 nsQAppInstance::nsQAppInstance(int gArgc, char** gArgv)
   : QApplication(gArgc, gArgv)
 {
 }
 
 void nsQAppInstance::AddRef(void) {
   if (qApp) return;
-  if (!sQAppInstance)
+  if (!sQAppInstance) {
+    const char *graphicsSystem = PR_GetEnv("MOZ_QT_GRAPHICSSYSTEM");
+    if (graphicsSystem)
+      QApplication::setGraphicsSystem(QString(graphicsSystem));
     sQAppInstance = new nsQAppInstance(gArgc, gArgv);
+  }
   sQAppRefCount++;
 }
 
 void nsQAppInstance::Release(void) {
   if (sQAppInstance && !--sQAppRefCount) {
     delete sQAppInstance;
     sQAppInstance = NULL;
   }