From b8e8be71ecdae89b7518c534eb545b4fb4556dbd Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 10 Dec 2009 21:23:25 +0000 Subject: [PATCH] 2009-12-10 22:22 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/hbqt_hbqmainwindow.cpp * contrib/hbxbp/xbpgeneric.prg + Replaced HB_MUTEXCREATE() and HB_MUTEXDESTROY() with automatic initialization and deinitialization. ; NOTE: From now on HBQT needs to be requested by apps willing to use HBQT, with: REQUEST HB_QT This will ensure in the future that all init and deinit procedure are done correctly. It also makes it safe to use QT even from INIT and EXIT PROCECUREs. * contrib/hbqt/tests/demoqt.prg * contrib/hbxbp/tests/demoxbp.prg * contrib/hbide/hbide.prg + Added REQUEST HB_QT. --- harbour/ChangeLog | 17 +++++++++++++++ harbour/contrib/hbide/hbide.prg | 2 ++ harbour/contrib/hbqt/hbqt_hbqmainwindow.cpp | 23 +++++++++++++++++++-- harbour/contrib/hbqt/tests/demoqt.prg | 2 ++ harbour/contrib/hbxbp/tests/demoxbp.prg | 2 ++ harbour/contrib/hbxbp/xbpgeneric.prg | 5 ----- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c05ad85720..f7f65081eb 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,23 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-10 22:22 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbqt/hbqt_hbqmainwindow.cpp + * contrib/hbxbp/xbpgeneric.prg + + Replaced HB_MUTEXCREATE() and HB_MUTEXDESTROY() with + automatic initialization and deinitialization. + ; NOTE: From now on HBQT needs to be requested by apps + willing to use HBQT, with: + REQUEST HB_QT + This will ensure in the future that all init and + deinit procedure are done correctly. It also makes it + safe to use QT even from INIT and EXIT PROCECUREs. + + * contrib/hbqt/tests/demoqt.prg + * contrib/hbxbp/tests/demoxbp.prg + * contrib/hbide/hbide.prg + + Added REQUEST HB_QT. + 2009-12-10 21:49 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbatomic.h * removed 'static inline' from OpenWatcom ASM functions defined diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index f4857a167b..671388d489 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -78,6 +78,8 @@ /*----------------------------------------------------------------------*/ +REQUEST HB_QT + STATIC s_resPath STATIC s_pathSep diff --git a/harbour/contrib/hbqt/hbqt_hbqmainwindow.cpp b/harbour/contrib/hbqt/hbqt_hbqmainwindow.cpp index 04f5638630..73a54ccd92 100644 --- a/harbour/contrib/hbqt/hbqt_hbqmainwindow.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqmainwindow.cpp @@ -57,6 +57,7 @@ #include "hbapiitm.h" #include "hbthread.h" #include "hbvm.h" +#include "hbinit.h" #include "hbqt.h" @@ -293,14 +294,18 @@ HB_FUNC( QT_HBQMAINWINDOW_DESTROY ) hbqt_par_HBQMainWindow( 1 )->~HBQMainWindow(); } -HB_FUNC( QT_MUTEXCREATE ) +static void hbqt_hbqmainwindow_init( void * cargo ) { + HB_SYMBOL_UNUSED( cargo ); + if( s_mutex == NULL ) s_mutex = hb_threadMutexCreate(); } -HB_FUNC( QT_MUTEXDESTROY ) +static void hbqt_hbqmainwindow_exit( void * cargo ) { + HB_SYMBOL_UNUSED( cargo ); + if( s_mutex != NULL ) { hb_itemRelease( s_mutex ); @@ -308,4 +313,18 @@ HB_FUNC( QT_MUTEXDESTROY ) } } +HB_FUNC( HB_QT ) {;} + +HB_CALL_ON_STARTUP_BEGIN( _hbqt_hbqmainwindow_initialize_ ) + hb_vmAtInit( hbqt_hbqmainwindow_init, NULL ); + hb_vmAtExit( hbqt_hbqmainwindow_exit, NULL ); +HB_CALL_ON_STARTUP_END( _hbqt_hbqmainwindow_initialize_ ) + +#if defined( HB_PRAGMA_STARTUP ) + #pragma startup _hbqt_hbqmainwindow_initialize_ +#elif defined( HB_DATASEG_STARTUP ) + #define HB_DATASEG_BODY HB_DATASEG_FUNC( _hbqt_hbqmainwindow_initialize_ ) + #include "hbiniseg.h" +#endif + #endif diff --git a/harbour/contrib/hbqt/tests/demoqt.prg b/harbour/contrib/hbqt/tests/demoqt.prg index a89849b603..46bf5c5349 100644 --- a/harbour/contrib/hbqt/tests/demoqt.prg +++ b/harbour/contrib/hbqt/tests/demoqt.prg @@ -87,6 +87,8 @@ STATIC qApp +REQUEST HB_QT + /*----------------------------------------------------------------------*/ INIT PROCEDURE Qt_Start() diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index cd4830c4ff..67e4c0d992 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -69,6 +69,8 @@ /*----------------------------------------------------------------------*/ +REQUEST HB_QT + REQUEST DbfCdx #define TAB_1 1 diff --git a/harbour/contrib/hbxbp/xbpgeneric.prg b/harbour/contrib/hbxbp/xbpgeneric.prg index fc4074598b..d37c6284ed 100644 --- a/harbour/contrib/hbxbp/xbpgeneric.prg +++ b/harbour/contrib/hbxbp/xbpgeneric.prg @@ -97,10 +97,7 @@ THREAD STATIC t_oEventLoop INIT PROCEDURE hbxbp_Start() - Qt_MutexCreate() - t_oDummy := XbpObject():new() - s_oApp := QApplication():new() RETURN @@ -121,8 +118,6 @@ EXIT PROCEDURE hbxbp_End() s_oApp:oWidget:pPtr := 0 #endif - Qt_MutexDestroy() - RETURN /*----------------------------------------------------------------------*/