Index: /trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 2491)
+++ /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 2492)
@@ -321,7 +321,8 @@
 if (myImgApp)  { 
   string str = '/' + dirname;
-  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+  if ( !_fgimgapp )  myImgApp->LockMutex();
   (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
-  }
+  if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
+}
 if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
 return(true);
@@ -355,6 +356,7 @@
 
 if (myImgApp) {
-  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+  if ( !_fgimgapp )  myImgApp->LockMutex();
   (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
+  if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
 }
 myDirs->erase(it);
@@ -497,6 +499,7 @@
 for(ii=odel.begin(); ii != odel.end(); ii++)  DelObj(*ii,true);
 if (myImgApp) {
-  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+  if ( !_fgimgapp )  myImgApp->LockMutex();
   (myImgApp->ObjMgrW())->UpdateList(did);
+  if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
 }
 }
@@ -607,9 +610,10 @@
 
 if (myImgApp != NULL) {
-  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+  if ( !_fgimgapp )  myImgApp->LockMutex();
   if ( (myImgApp->ObjMgrW())->Visible() ) {
     string oln = nobj + "  (T= " + no.obja->GetDataObjType() + ")" ; 
     (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
   }
+  if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
 }
 if (verbeux) cout << "NamedObjMgr::AddObj()  Object " << nom << " ( "  
@@ -689,5 +693,5 @@
 
 if (myImgApp != NULL) {
-  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+  if ( !_fgimgapp )  myImgApp->LockMutex();
   if ( (myImgApp->ObjMgrW())->Visible() ) {
     (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
@@ -695,4 +699,5 @@
     (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
   }
+  if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
 }
 if (verbeux) 
@@ -741,6 +746,10 @@
 if (myImgApp) {
 //DBG  cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl; 
+// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
+  bool fglock = (_fgimgapp) ? false : true;
+  if (fglock) myImgApp->LockMutex();
   for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++) 
       myImgApp->DelWRsId((*ii));
+  if (fglock) myImgApp->UnlockMutex(true);
 }
 delete (*it).second.obja;  // destruction de l'adaptateur 
@@ -748,9 +757,10 @@
 
 if (myImgApp != NULL) {
-  if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+  if ( !_fgimgapp )  myImgApp->LockMutex();
   if ( (myImgApp->ObjMgrW())->Visible() ) {
     int olid = (*it).second.oid;
     (myImgApp->ObjMgrW())->DelObjList(did, olid);
   }
+  if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
 }
 myObjs->erase(it);
@@ -1593,5 +1603,5 @@
 if (!myImgApp)  return;
 ZSync(*myMutex);
-if ( !_fgimgapp )  ZSync(myImgApp->getMutex(),2);
+if ( !_fgimgapp )  myImgApp->LockMutex();
 
 (myImgApp->ObjMgrW())->ClearObjList();
@@ -1606,4 +1616,6 @@
   (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
   }
+
+if ( !_fgimgapp )  myImgApp->UnlockMutex(true);
 }
 
Index: /trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 2491)
+++ /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 2492)
@@ -2,4 +2,5 @@
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <string.h>
 
@@ -406,5 +407,5 @@
   {
     while (!_fgstop) {
-      usleep(1000);
+      usleep(2000);
       _app->getMutex().broadcast();
     }
@@ -443,5 +444,5 @@
 
 thr_glsyn.lock(); //  <ZThread> 
-//DBG int klp = 0;
+//DEL-DBG int klp = 0;
 while (mStop) {
   fg_glsynlock = true;
@@ -451,9 +452,10 @@
     XtDispatchEvent(&evt);
     nevtproc++;
-    if (nevtproc >= 50)  break;
+    if (nevtproc >= 200)  break;
   }
   fg_glsynlock = false;
+  //DBG cout << " "DBG-Run:: Going to wait ... " << klp << endl;
   thr_glsyn.wait();  //  <ZThread> 
-  //  cout << "DBG-Run:: Out of wait " << ++klp << endl;  
+  //DBG cout << "DBG-Run:: Out of wait " << ++klp << endl;  
     //  usleep(1000);
 }
@@ -626,4 +628,28 @@
 }
 
+class SyncPIS {
+public:
+  explicit SyncPIS(ZMutex & mtx, bool fglock=true, int sigbr=0) 
+  {
+  _mtx = &mtx; _sigbr = sigbr; 
+  _fglock = fglock; 
+  if (_fglock)  mtx.lock(); 
+  }
+  ~SyncPIS() 
+  { 
+    if (_fglock && (_mtx != NULL) ) { 
+      if (_sigbr == 1) _mtx->signal(); 
+      else  if (_sigbr == 2) _mtx->broadcast(); 
+      _mtx->unlock(); 
+    }
+  }
+
+private:
+  ZMutex * _mtx;
+  int _sigbr;
+  bool _fglock;
+  inline	SyncPIS() {_mtx = NULL; _sigbr = 0; _fglock = false; }
+};
+
 
 /* --Methode-- */
@@ -656,5 +682,5 @@
 
 // <ZThread> global PIApplication event loop synchronisation
-if (fglock) ZSync zs(thr_glsyn, 2);  
+SyncPIS zs(getMutex(), fglock, 2);
 
 // Choix de la taille de fenetre
@@ -726,5 +752,5 @@
 
 // <ZThread> global PIApplication event loop synchronisation
-if (fglock) ZSync zs(thr_glsyn, 2);  
+SyncPIS zs(getMutex(), fglock, 2);
 
 // Trace en superpoistion
@@ -830,5 +856,5 @@
 
 // <ZThread> global PIApplication event loop synchronisation
-if (fglock) ZSync zs(thr_glsyn, 2);  
+SyncPIS zs(getMutex(), fglock, 2);
 
 // Trace en superpoistion
Index: /trunk/SophyaPI/PIext/pistdimgapp.h
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 2491)
+++ /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 2492)
@@ -58,4 +58,7 @@
      virtual void   Run();
      inline ZMutex &   getMutex() { return thr_glsyn; }
+     inline void       LockMutex() { thr_glsyn.lock(); }
+     inline void       UnlockMutex(bool fgbr=false) 
+        { thr_glsyn.broadcast(); thr_glsyn.unlock(); }
      inline bool       isGlSyncLocked() { return fg_glsynlock; }
 
