From: prascle Date: Mon, 26 Jan 2004 16:40:25 +0000 (+0000) Subject: PR: Multi Thread and Mutex Qt X-Git-Tag: mergefrom_trunk_01Feb04~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b271a9dbb3c269936faaf87462925a85d51cb4f0;p=modules%2Fvisu.git PR: Multi Thread and Mutex Qt --- diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index e23f6210..4b8567ab 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -51,34 +51,34 @@ namespace VISU{ } //=========================================================================== - static int mySCnt = 0; - static int myQCnt = 0; - static int myIsBatchMode = 0; +// static int mySCnt = 0; +// static int myQCnt = 0; +// static int myIsBatchMode = 0; - Mutex::Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay) : - myQApp(theQApp), isQAppLocked(theQApp->locked()), myDelay(theDelay), - myMutex(theMutex), isSessionLocked(theMutex->locked()) - { - if(MYDEBUG) MESSAGE("Mutex::Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); - if(!myIsBatchMode && isQAppLocked) myIsBatchMode++; - if(!isSessionLocked && !mySCnt) { myMutex->lock();}; mySCnt++; - if(!isQAppLocked && !myQCnt) { - myQApp->lock(); - myQApp->syncX(); - }; - myQCnt++; - } - Mutex::~Mutex(){ - myQCnt--; - if(!isQAppLocked && !myQCnt) { - myQApp->flushX(); - //if(myDelay > 0) - myQApp->processEvents(myDelay+3); - myQApp->unlock(); - } - mySCnt--; if(!isSessionLocked && !mySCnt) { myMutex->unlock();} - if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); - } +// Mutex::Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay) : +// myQApp(theQApp), isQAppLocked(theQApp->locked()), myDelay(theDelay), +// myMutex(theMutex), isSessionLocked(theMutex->locked()) +// { +// if(MYDEBUG) MESSAGE("Mutex::Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); +// if(!myIsBatchMode && isQAppLocked) myIsBatchMode++; +// if(!isSessionLocked && !mySCnt) { myMutex->lock();}; mySCnt++; +// if(!isQAppLocked && !myQCnt) { +// myQApp->lock(); +// myQApp->syncX(); +// }; +// myQCnt++; +// } +// Mutex::~Mutex(){ +// myQCnt--; +// if(!isQAppLocked && !myQCnt) { +// myQApp->flushX(); +// //if(myDelay > 0) +// myQApp->processEvents(myDelay+3); +// myQApp->unlock(); +// } +// mySCnt--; if(!isSessionLocked && !mySCnt) { myMutex->unlock();} +// if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); +// } //=========================================================================== diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index 68f5d16c..a49c4b16 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -45,6 +45,7 @@ #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "Utils_CorbaException.hxx" +#include "SALOMEGUI_VisuMutex.hxx" #include "utilities.h" #include @@ -78,14 +79,14 @@ namespace VISU{ //=========================================================================== - class Mutex{ - QMutex* myMutex; - QApplication* myQApp; - int isQAppLocked, isSessionLocked, myDelay; - public: - Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay = 0); - ~Mutex(); - }; +// class Mutex{ +// QMutex* myMutex; +// QApplication* myQApp; +// int isQAppLocked, isSessionLocked, myDelay; +// public: +// Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay = 0); +// ~Mutex(); +// }; //=========================================================================== diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index f6420925..61d85b13 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -393,7 +393,7 @@ namespace VISU{ //omni_mutex_lock aMutexLock(aMutex); if(MYDEBUG) MESSAGE("VISU_Gen_i::GetViewManager : "<_this()); } diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 1035f51f..6c955c41 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -235,7 +235,7 @@ namespace VISU{ */ ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) { if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i"); - Mutex mt(myMutex,qApp,MYDELAY); + SMutex mt(myMutex,qApp,MYDELAY); myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); //TViewManager* aTViewManager = new TViewManager(theStudy); //aTViewManager->start(); @@ -252,7 +252,7 @@ namespace VISU{ VISU::View3D_ptr ViewManager_i::Create3DView(){ - Mutex mt(myMutex,qApp,MYDELAY); + //Mutex mt(myMutex,qApp,MYDELAY); if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView"); VISU::View3D_i* pView = new View3D_i(myStudyDocument); if(pView->Create(1) != NULL) @@ -324,6 +324,8 @@ namespace VISU{ void ViewManager_i::ProcessEvents() { while (true) { + MESSAGE("--- must never be called ! ---"); + ASSERT(0); qApp->lock(); qApp->syncX(); qApp->flushX();