Use QMutexLocker in Qt driver. RAII is always better than managing
resources by hand.
Index: qt.cpp
===================================================================
--- qt.cpp (revision 10054)
+++ qt.cpp (working copy)
@@ -32,6 +32,7 @@
#include "qt.h"
+#include <QMutexLocker>
// global variables initialised in init(), used in tidy()
// QApplication* app=NULL;
@@ -82,7 +83,7 @@
bool initQtApp(bool isGUI)
{
- QtPLDriver::mutex.lock();
+ QMutexLocker locker(&QtPLDriver::mutex);
bool res=false;
++appCounter;
if(qApp==NULL && appCounter==1)
@@ -96,13 +97,12 @@
new QApplication(argc, argv, isGUI);
res=true;
}
- QtPLDriver::mutex.unlock();
return res;
}
void closeQtApp()
{
- QtPLDriver::mutex.lock();
+ QMutexLocker locker(&QtPLDriver::mutex);
--appCounter;
if(qApp!=NULL && appCounter==0)
{
@@ -112,7 +112,6 @@
delete[] argv;
argv=NULL;
}
- QtPLDriver::mutex.unlock();
}
/*---------------------------------------------------------------------
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <[email protected]>*/
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel