From 9f2554ebb1cbba359710de4a16d634420c4a164f Mon Sep 17 00:00:00 2001 From: smh Date: Tue, 20 Apr 2004 05:50:01 +0000 Subject: [PATCH] Change functionality of VISU::Mutex class --- src/VISU_I/VISUConfig.cc | 30 ++++++------------------ src/VISU_I/VISUConfig.hh | 5 ++-- src/VISU_I/VISU_Gen_i.cc | 50 ++++++++++++++++++++-------------------- src/VISU_I/VISU_Gen_i.hh | 2 +- 4 files changed, 35 insertions(+), 52 deletions(-) diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index e2229e19..65c7f5f8 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -58,32 +58,16 @@ namespace VISU{ //=========================================================================== 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(QMutex* theMutex): myMutex(theMutex){ + if(MYDEBUG) MESSAGE("Mutex::Mutex : "<lock(); } 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)); + if(!(--mySCnt)) + myMutex->unlock(); + if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); TCollection_AsciiString aTmpDir = @@ -232,7 +232,7 @@ namespace VISU{ if(myMutex){ CORBA::String_var aString(""); if(strcmp(aLocalPersistentID,"") != 0) { - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); Storable* aStorable = Storable::Create(theSObject,VisuTmpDir.c_str(),aLocalPersistentID); if(aStorable != NULL) aString = aStorable->GetID(); @@ -248,7 +248,7 @@ namespace VISU{ { if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<(GetServant(anObj).in()); if(pStorable != NULL){ - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); aString = pStorable->ToString().c_str(); return aString._retn(); } @@ -404,7 +404,7 @@ namespace VISU{ //omni_mutex_lock aMutexLock(aMutex); if(MYDEBUG) MESSAGE("VISU_Gen_i::GetViewManager : "<_this()); } @@ -414,7 +414,7 @@ namespace VISU{ SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){ if(myMutex){ if(myStudyDocument->GetProperties()->IsLocked()) return SALOMEDS::SObject::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument); return aRes._retn(); } @@ -430,7 +430,7 @@ namespace VISU{ Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){ if(myMutex){ if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); aFileInfo.setFile(theFileName); Result_i* pResult = new Result_i(myStudyDocument); if(pResult->Create(theFileName) != NULL) @@ -446,7 +446,7 @@ namespace VISU{ Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){ if(myMutex){ if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); VISU::Result_var aResult; aFileInfo.setFile(theFileName); Result_i* pResult = new Result_i(myStudyDocument,Result_i::eRestoredFile); @@ -461,7 +461,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMed : "<GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); Result_i* pResult = new Result_i(myStudyDocument); if(pResult->Create(theMedSObject) != NULL) return pResult->_this(); @@ -477,7 +477,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedField : "<GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); Result_i* pResult = new Result_i(myStudyDocument); if(pResult->Create(theField) != NULL) return pResult->_this(); @@ -493,7 +493,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::MeshOnEntity : "<GetProperties()->IsLocked()) return Mesh::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ Mesh_i* aPresent = new Mesh_i(pResult); if(aPresent->Create(theMeshName,theEntity) != NULL) @@ -513,7 +513,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::FamilyMeshOnEntity : "<GetProperties()->IsLocked()) return Mesh::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ Mesh_i* aPresent = new Mesh_i(pResult); if(aPresent->Create(theMeshName,theEntity,theFamilyName) != NULL) @@ -532,7 +532,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::GroupMesh : "<GetProperties()->IsLocked()) return Mesh::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ Mesh_i* aPresent = new Mesh_i(pResult); if(aPresent->Create(theMeshName,theGroupName) != NULL) @@ -599,7 +599,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateTable : "<GetProperties()->IsLocked()) return Table::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); Table_i* pPresent = new Table_i(myStudyDocument,theTableEntry); if(pPresent->Create() != NULL) return pPresent->_this(); @@ -615,7 +615,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateCurve : "<GetProperties()->IsLocked()) return Curve::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); PortableServer::POA_ptr aPOA = GetPOA(); Table_i* pTable = dynamic_cast(aPOA->reference_to_servant(theTable)); Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow); @@ -632,7 +632,7 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateContainer : "<GetProperties()->IsLocked()) return Container::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); Container_i* pPresent = new Container_i(myStudyDocument); if(pPresent->Create() != NULL) return pPresent->_this(); @@ -647,9 +647,9 @@ namespace VISU{ Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){ if(myMutex){ if(myStudyDocument->GetProperties()->IsLocked()) return Animation::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateAnimation : "<_this(); }else return VISU::Animation::_nil(); @@ -661,7 +661,7 @@ namespace VISU{ void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ if(MYDEBUG) MESSAGE("VISU_Gen_i::Close : "<GetStudy(); //if(!aStudy->_is_nil()){ // SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(theComponent); @@ -717,7 +717,7 @@ namespace VISU{ { if(MYDEBUG) MESSAGE("VISU_Gen_i::PublishInStudy : "<(GetServant(theObject).in()); if (!aResultObj) return aResultSO._retn(); @@ -732,7 +732,7 @@ namespace VISU{ CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanCopy : "<FindAttribute(anAttr, "AttributeIOR")) return false; try { @@ -763,7 +763,7 @@ namespace VISU{ SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { if(myMutex){ - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); theObjectID = 0; SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; @@ -844,7 +844,7 @@ namespace VISU{ SALOMEDS::SObject_ptr theObject) { if(MYDEBUG) MESSAGE("VISU_Gen_i::PasteInto : "<GetProperties()->IsLocked()) return TPrs3d::_nil(); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex); if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ if(TPrs3d_i::IsPossible(pResult,theMeshName,theEntity,theFieldName,int(theIteration))){ TPrs3d_i* aPresent = new TPrs3d_i(pResult,theAddToStudy); -- 2.39.2