Salome HOME
Fix a bug of config file for RedHat 9 - correct binaries distribution path
[tools/install.git] / src / SALOME_InstallWizard.cxx
index 9a83803f0d64b2763397267427b56b4b14491755..87fe009202beb1ffcceed957e8ca8b43a18cae7a 100644 (file)
@@ -36,6 +36,7 @@
 #include <qfile.h>
 #include <qthread.h>
 #include <qwaitcondition.h>
+#include <qmutex.h>
 
 #ifdef WNT
 #include <iostream.h>
@@ -58,7 +59,8 @@ QString tmpDirName() { return QString(  "/INSTALLWORK" ) + QString::number( getp
  *  Class for executing systen commands
  */
 // ================================================================
-QWaitCondition myWC;
+static QMutex myMutex(false);
+static QWaitCondition myWC;
 class QProcessThread: public QThread
 {
   typedef QPtrList<QCheckListItem> ItemList;
@@ -81,9 +83,11 @@ public:
       QCheckListItem* item = myItems.first();
       myCommands.pop_front();
       myItems.removeFirst();
+      myMutex.lock();
       SALOME_InstallWizard::postValidateEvent( myWizard, result, (void*)item );
       if ( hasCommands() )
-       myWC.wait();
+       myWC.wait(&myMutex);
+      myMutex.unlock();
     };
   }
 
@@ -1048,30 +1052,32 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
     QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
     QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
     myThread->clearCommands();
-    for ( unsigned i = 0; i < natives.count(); i++ ) {
-      item = findItem( natives[ i ] );
-      if ( item ) {
-       QString dependOn = productsMap[ item ].getDependancies().join(" ");
-       QString script = "cd ./config_files/;" + item->text(2) + " try_native " +
-               QFileInfo( tmpFolder ).absFilePath() + " " + QDir::currentDirPath() + "/Products " + QFileInfo( tgtFolder ).absFilePath() + " " +
-               QUOTE(dependOn) + " " + item->text(0);
+    if ( natives.count() > 0 ) {
+      for ( unsigned i = 0; i < natives.count(); i++ ) {
+       item = findItem( natives[ i ] );
+       if ( item ) {
+         QString dependOn = productsMap[ item ].getDependancies().join(" ");
+         QString script = "cd ./config_files/;" + item->text(2) + " try_native " +
+                 QFileInfo( tmpFolder ).absFilePath() + " " + QDir::currentDirPath() + "/Products " + QFileInfo( tgtFolder ).absFilePath() + " " +
+                 QUOTE(dependOn) + " " + item->text(0);
 
-       myThread->addCommand( item, script );
-      }
-      else {
-       QMessageBox::warning( this, 
-                             tr( "Warning" ), 
-                             tr( "%The product %1 %2 required for installation.\n"
-                                 "Please, add this product in config.xml file.").arg(item->text(0)).arg(item->text(1)),
-                             QMessageBox::Ok, 
-                             QMessageBox::NoButton, 
-                             QMessageBox::NoButton );
-       return false;
+         myThread->addCommand( item, script );
+       }
+       else {
+         QMessageBox::warning( this, 
+                               tr( "Warning" ), 
+                               tr( "%The product %1 %2 required for installation.\n"
+                                   "Please, add this product in config.xml file.").arg(item->text(0)).arg(item->text(1)),
+                               QMessageBox::Ok, 
+                               QMessageBox::NoButton, 
+                               QMessageBox::NoButton );
+         return false;
+       }
       }
+      WarnDialog::showWarnDlg( this, true );
+      myThread->start();
+      return true; // return in order to avoid default postValidateEvent() action
     }
-    WarnDialog::showWarnDlg( this, true );
-    myThread->start();
-    return true; // return in order to avoid default postValidateEvent() action
   }
   return InstallWizard::acceptData( pageTitle );
 }
@@ -1278,14 +1284,14 @@ void SALOME_InstallWizard::launchScript()
     }
   }
   // <Next> button
-  nextButton()->setEnabled( true );
+  setNextEnabled( true );
   nextButton()->setText( tr( "&Next >" ) );
   QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
   QToolTip::add  ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
   nextButton()->disconnect();
   connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
   // <Back> button
-  backButton()->setEnabled( true );
+  setBackEnabled( true );
   // script parameters
   passedParams->clear();
   passedParams->setEnabled( false );
@@ -1507,7 +1513,7 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
       // reconnect Next button - to use it as Start button
       nextButton()->disconnect();
       connect( nextButton(), SIGNAL( clicked() ), this, SLOT( onStart() ) );
-      nextButton()->setEnabled( true );
+      setNextEnabled( true );
       // reconnect Cancel button to terminate process
       cancelButton()->disconnect();
       connect( cancelButton(), SIGNAL( clicked() ), this, SLOT( tryTerminate() ) );
@@ -1604,9 +1610,9 @@ void SALOME_InstallWizard::onStart()
   if ( !toInstall.isEmpty() ) {
     clean(false); // VSR 07/02/05 - bug fix: first we should clear temporary directory
     // disable <Next> button
-    nextButton()->setEnabled( false );
+    setNextEnabled( false );
     // disable <Back> button
-    backButton()->setEnabled ( false );
+    setBackEnabled( false );
     // enable script parameters line edit
     // VSR commented: 18/09/03: passedParams->setEnabled( true );
     // VSR commented: 18/09/03: passedParams->setFocus();
@@ -1665,14 +1671,14 @@ void SALOME_InstallWizard::productInstalled( )
     passedParams->setEnabled( false );
     QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
     // enable <Next> button
-    nextButton()->setEnabled( true );
+    setNextEnabled( true );
     nextButton()->setText( tr( "&Next >" ) );
     QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
     QToolTip::add  ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
     nextButton()->disconnect();
     connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
     // enable <Back> button
-    backButton()->setEnabled( true );
+    setBackEnabled( true );
   }
 }
 // ================================================================
@@ -1911,6 +1917,8 @@ void SALOME_InstallWizard::processValidateEvent( const int val, void* data )
     InstallWizard::processValidateEvent( val, data );
     return;
   }
+  myMutex.lock();
+  myMutex.unlock();
   QCheckListItem* item = (QCheckListItem*)data;
   if ( val > 0 ) {
     if ( val == 2 ) {
@@ -1924,8 +1932,11 @@ void SALOME_InstallWizard::processValidateEvent( const int val, void* data )
                                QMessageBox::NoButton ) == QMessageBox::No ) {
        myThread->clearCommands();
        myWC.wakeAll();
+       setNextEnabled( true );
+       setBackEnabled( true );
        return;
       }
+      WarnDialog::showWarnDlg( this, true );
     }
     else {
       WarnDialog::showWarnDlg( 0, false );
@@ -1935,9 +1946,11 @@ void SALOME_InstallWizard::processValidateEvent( const int val, void* data )
                           QMessageBox::Ok, 
                           QMessageBox::NoButton, 
                           QMessageBox::NoButton );
-      productsView->setNone( item );
       myThread->clearCommands();
       myWC.wakeAll();
+      setNextEnabled( true );
+      setBackEnabled( true );
+      productsView->setNone( item );
       return;
     }
   }