Index: trunk/source/interfaces/History
===================================================================
--- trunk/source/interfaces/History	(revision 873)
+++ trunk/source/interfaces/History	(revision 874)
@@ -1,3 +1,3 @@
-$Id: History,v 1.101 2008/10/15 09:09:47 lgarnier Exp $
+$Id: History,v 1.102 2008/10/24 13:23:22 lgarnier Exp $
 -------------------------------------------------------------------
 
@@ -18,4 +18,8 @@
      ----------------------------------------------------------
 
+24 October, Laurent Garnier
+ - Change GEANT4_QT_DEBUG flag by QTDEBUG
+ - Suppress unuseful DEBUG messages
+
 15 October, Laurent Garnier
  - Fix a problem on some linux with QApplication. But this is NOT the good way to do it...
Index: trunk/source/interfaces/basic/include/G4UIQt.hh
===================================================================
--- trunk/source/interfaces/basic/include/G4UIQt.hh	(revision 873)
+++ trunk/source/interfaces/basic/include/G4UIQt.hh	(revision 874)
@@ -80,5 +80,5 @@
 
 public: // With description
-  G4UIQt(int*,char**);
+  G4UIQt(int,char**);
   // (argv, argc) or (0, NULL) had to be given.
   G4UIsession* SessionStart();
Index: trunk/source/interfaces/basic/src/G4UIQt.cc
===================================================================
--- trunk/source/interfaces/basic/src/G4UIQt.cc	(revision 873)
+++ trunk/source/interfaces/basic/src/G4UIQt.cc	(revision 874)
@@ -25,10 +25,8 @@
 //
 //
-// $Id: G4UIQt.cc,v 1.20 2008/10/15 09:09:47 lgarnier Exp $
+// $Id: G4UIQt.cc,v 1.21 2008/10/24 13:23:22 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
 // L. Garnier
-
-//#define GEANT4_QT_DEBUG
 
 #ifdef G4UI_BUILD_QT_SESSION
@@ -102,5 +100,5 @@
 */
 G4UIQt::G4UIQt (
- int* argc
+ int argc
 ,char** argv
 )
@@ -140,5 +138,5 @@
   fMainWindow = new QMainWindow();
 
-#ifdef GEANT4_QT_DEBUG
+#ifdef G4DEBUG
   printf("G4UIQt::Initialise after main window creation\n");
 #endif
@@ -201,11 +199,4 @@
 #endif
   fTextArea->setReadOnly(true);
-
-
-#ifdef GEANT4_QT_DEBUG
-  printf("G4UIQt::   2\n");
-#endif
-
-
 
   layoutTop->addWidget(fTextArea);
@@ -306,7 +297,4 @@
 
 
-#ifdef GEANT4_QT_DEBUG
-  printf("disable secondary loop\n");
-#endif
   interactorManager->DisableSecondaryLoop (); // TO KEEP
   if ((QApplication*)interactorManager->GetMainInteractor())
@@ -323,7 +311,4 @@
 
   interactorManager->EnableSecondaryLoop ();
-#ifdef GEANT4_QT_DEBUG
-  printf("enable secondary loop\n");
-#endif
   return this;
 }
@@ -369,7 +354,4 @@
   if (!aState) return;
 
-#ifdef GEANT4_QT_DEBUG
-  printf("G4UIQt::PauseSessionStart\n");
-#endif
   if(aState=="G4_pause> ") {  // TO KEEP
     SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
@@ -394,7 +376,4 @@
   if (!aPrompt) return;
 
-#ifdef GEANT4_QT_DEBUG
-  printf("G4UIQt::SecondaryLoop\n");
-#endif
   G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
   Prompt(aPrompt); // TO KEEP
@@ -1005,5 +984,5 @@
 )
 {
-#ifdef GEANT4_QT_DEBUG
+#ifdef G4DEBUG
   printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
 #endif
@@ -1017,5 +996,5 @@
 )
 {
-#ifdef GEANT4_QT_DEBUG
+#ifdef G4DEBUG
   printf("G4UIQt::ExitHelp SHOULD NEVER GO HERE");
 #endif
@@ -1615,6 +1594,4 @@
       commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
 #endif
-#ifdef GEANT4_QT_DEBUG
-#endif
     }
     
Index: trunk/source/interfaces/common/include/G4Qt.hh
===================================================================
--- trunk/source/interfaces/common/include/G4Qt.hh	(revision 873)
+++ trunk/source/interfaces/common/include/G4Qt.hh	(revision 874)
@@ -51,5 +51,5 @@
 public:
   static G4Qt* getInstance();
-  static G4Qt* getInstance(int*,char**,char*);
+  static G4Qt* getInstance(int,char**,char*);
   G4bool Inited();
   void* GetEvent();
@@ -57,5 +57,5 @@
   virtual ~G4Qt();                     
 private:
-  G4Qt (int*,char**,char*);                     
+  G4Qt (int,char**,char*);                     
   static G4Qt* instance; // Pointer to single instance.
 };
Index: trunk/source/interfaces/common/src/G4Qt.cc
===================================================================
--- trunk/source/interfaces/common/src/G4Qt.cc	(revision 873)
+++ trunk/source/interfaces/common/src/G4Qt.cc	(revision 874)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4Qt.cc,v 1.9 2008/10/15 09:09:47 lgarnier Exp $
+// $Id: G4Qt.cc,v 1.10 2008/10/24 13:23:22 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
@@ -56,5 +56,5 @@
 /***************************************************************************/
 G4Qt* G4Qt::getInstance (
- int*    a_argn
+ int    a_argn
 ,char** a_args
 ,char*  a_class
@@ -70,5 +70,5 @@
 /***************************************************************************/
 G4Qt::G4Qt (
- int*    a_argn
+ int    a_argn
 ,char** a_args
 ,char*  a_class
@@ -77,5 +77,5 @@
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
 {
-#ifdef GEANT4_QT_DEBUG
+#ifdef G4DEBUG
   printf("G4Qt::G4Qt try to inited Qt\n");
 #endif
@@ -88,6 +88,7 @@
       SetMainInteractor (qApp);
       //#endif
-      SetArguments      (*a_argn,a_args);
-#ifdef GEANT4_QT_DEBUG
+      SetArguments      (a_argn,a_args);
+
+#ifdef G4DEBUG
       printf("G4Qt::G4Qt alredy inited in external \n");
 #endif
@@ -95,26 +96,56 @@
 
     if(QtInited==FALSE) {  //Qt should be Inited once !
-#ifdef GEANT4_QT_DEBUG
-      printf("G4Qt::G4Qt inited Qt\n");
-#endif
+      // Then two cases :
+      // - It is the first time we create G4UI  (argc!=0)
+      //   -> Inited and register
+      // - It is the first time we create G4VIS  (arc == 0)
+      //   -> Inited and NOT register
+
+      int argc;
+      char ** test;
+      if (a_argn != 0) {
+        SetArguments      (a_argn,a_args);
+#ifdef G4DEBUG
+      printf("G4Qt::G4Qt inited, first time creating UI \n");
+#endif
+      } else { //argc = 0
+        test = GetArguments(&argc);
+
+#ifdef G4DEBUG
+
+        printf("G4Qt::G4Qt inited, create new QtVis\n");
+        printf("G4Qt::G4Qt arguments avant %s\n",a_args[0]);
+        printf("G4Qt::G4Qt arguments avant %s\n",a_args[1]);
+        printf("G4Qt::G4Qt arguments avant %s\n",a_args[2]);
+        printf("G4Qt::G4Qt arguments avant %s\n",a_args[3]);
+        printf("G4Qt::G4Qt arguments apres %d\n",argc);
+        printf("G4Qt::G4Qt arguments apres %s \n",test[0]);
+        printf("G4Qt::G4Qt arguments apres %s \n",test[1]);
+        printf("G4Qt::G4Qt arguments apres %s \n",test[2]);
+        printf("G4Qt::G4Qt arguments apres %s \n",test[3]);
+#endif
+        if (argc == 0) {
+          G4cout        << "G4Qt : Unable to init Qt." << G4endl;
+          return;
+        }
+      }
 #if QT_VERSION < 0x040000
-      qApp = new QApplication (*a_argn, a_args);
+      qApp = new QApplication (a_argn, a_args);
       //    QApplication qApp(a_argn, a_args);
       //    if(&qApp == NULL) {
 #else
-      new QApplication (*a_argn, a_args);
-#endif
+      new QApplication (a_argn, a_args);
+#endif
+      
       if(!qApp) {
         
         G4cout        << "G4Qt : Unable to init Qt." << G4endl;
       } else {
+        if (a_argn != 0) {
+          SetMainInteractor (qApp);
+          SetArguments      (a_argn,a_args);
+        }
         QtInited  = TRUE;
-        //#if QT_VERSION < 0x040000
-        //      SetMainInteractor (&qApp);
-        //#else
-        SetMainInteractor (qApp);
-        //#endif
-        SetArguments      (*a_argn,a_args);
-#ifdef GEANT4_QT_DEBUG
+#ifdef G4DEBUG
         printf("G4Qt::G4Qt inited Qt END\n");
 #endif
@@ -122,5 +153,5 @@
     }
   }
-#ifdef GEANT4_QT_DEBUG
+#ifdef G4DEBUG
   if (qApp) {
     printf("G4Qt::qApp exist\n");
