From f28e124cabacb7e4a5879c7397abce7f7dfcb887 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 12 Jan 2010 18:40:54 +0000 Subject: [PATCH] 2010-01-12 19:39 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbsqlit3/hbsqlit3.c * contrib/hbfimage/fi_wrp.c ! Fixed to use hb_vmRequest*() in callbacks. * contrib/hbfimage/fi_wrp.c % Optimized FreeImageErrorHandler(). % FreeImageErrorHandler() made static. * Formatting. ; Please test and review. I didn't test these modifications at all. --- harbour/ChangeLog | 14 +++++++- harbour/contrib/hbfimage/fi_wrp.c | 54 ++++++++++++----------------- harbour/contrib/hbsqlit3/hbsqlit3.c | 24 +++++++++---- 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bdcfe9f1ef..7e024efe33 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,18 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-12 19:39 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbsqlit3/hbsqlit3.c + * contrib/hbfimage/fi_wrp.c + ! Fixed to use hb_vmRequest*() in callbacks. + + * contrib/hbfimage/fi_wrp.c + % Optimized FreeImageErrorHandler(). + % FreeImageErrorHandler() made static. + * Formatting. + + ; Please test and review. I didn't test these modifications at all. + 2010-01-11 10:21 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt_destruct.cpp + HBQT_SETCODECFORTR() @@ -35,7 +47,7 @@ * contrib/hbqt/hbqt_hbqmainwindow.cpp * contrib/hbqt/qtgui/QMainWindow.cpp * contrib/hbqt/qth/QMainWindow.qth - % Moved hbqt_QMainWindow_save(rest)Settings() from + % Moved hbqt_QMainWindow_save(rest)Settings() from hbqt_destruct.cpp to QMainWindow.cpp. 2010-01-12 16:44 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) diff --git a/harbour/contrib/hbfimage/fi_wrp.c b/harbour/contrib/hbfimage/fi_wrp.c index af6c96ee3a..5f375f0ee6 100644 --- a/harbour/contrib/hbfimage/fi_wrp.c +++ b/harbour/contrib/hbfimage/fi_wrp.c @@ -70,7 +70,7 @@ /* ************************* WRAPPED FUNCTIONS ****************************** */ /* static for error handler (see below FI_SETOUTPUTMESSAGE ) */ -static void *pErrorHandler = NULL; +static void * s_pErrorHandler = NULL; /* -------------------------------------------------------------------------- */ /* Init / Error routines ---------------------------------------------------- */ @@ -133,42 +133,34 @@ FreeImage error handler @param fif Format / Plugin responsible for the error @param message Error message */ -void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) +static void FreeImageErrorHandler( FREE_IMAGE_FORMAT fif, const char * message ) { - const char * format; - PHB_SYMB pSymbol; - - if( ! pErrorHandler ) + if( s_pErrorHandler ) { - /* Do nothing */ - return; + /*TraceLog( NULL, "ErrorHandle %p\n\r", s_pErrorHandler );*/ + + if( hb_vmRequestReenter() ) + { + const char * format = FreeImage_GetFormatFromFIF( fif ); + + /* launch error function at prg level */ + hb_vmPushSymbol( ( PHB_SYMB ) s_pErrorHandler ); + hb_vmPushNil(); + hb_vmPushString( format, strlen( format ) ); + hb_vmPushString( message, strlen( message ) ); + hb_vmDo( 2 ); + + hb_vmRequestRestore(); + } + else + hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, "FreeImageErrorHandler", 1, hb_paramError( 1 ) ); } - - pSymbol = (PHB_SYMB) pErrorHandler; - - /*TraceLog( NULL, "ErrorHandle %p\n\r", pErrorHandler );*/ - - if( ! pSymbol ) - { - hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, "FreeImageErrorHandler", 1, hb_paramError( 1 ) ); - return; - } - - format = FreeImage_GetFormatFromFIF(fif); - - /* launch error function at prg level */ - hb_vmPushSymbol( pSymbol ); - hb_vmPushNil(); - hb_vmPushString( format, strlen( format ) ); - hb_vmPushString( message, strlen( message ) ); - hb_vmDo( 2 ); - } HB_FUNC( FI_SETOUTPUTMESSAGE ) { - pErrorHandler = NULL; - FreeImage_SetOutputMessage(FreeImageErrorHandler); + s_pErrorHandler = NULL; + FreeImage_SetOutputMessage( FreeImageErrorHandler ); /* TraceLog( NULL, "PCount = %i\n\r", hb_pcount() ); */ @@ -177,7 +169,7 @@ HB_FUNC( FI_SETOUTPUTMESSAGE ) if( HB_ISPOINTER( 1 ) ) { /* Set the pointer */ - pErrorHandler = hb_parptr( 1 ); + s_pErrorHandler = hb_parptr( 1 ); } else if( HB_ISNIL( 1 ) ) { diff --git a/harbour/contrib/hbsqlit3/hbsqlit3.c b/harbour/contrib/hbsqlit3/hbsqlit3.c index 48aa015a05..bad44f26bf 100644 --- a/harbour/contrib/hbsqlit3/hbsqlit3.c +++ b/harbour/contrib/hbsqlit3/hbsqlit3.c @@ -253,7 +253,7 @@ static int callback( void *Cargo, int argc, char **argv, char **azColName ) { PHB_DYNS pSym = ( PHB_DYNS ) Cargo; - if( pSym ) + if( pSym && hb_vmRequestReenter() ) { PHB_ITEM pArrayValue = hb_itemArrayNew( argc ); PHB_ITEM pArrayColName = hb_itemArrayNew( argc ); @@ -277,6 +277,8 @@ static int callback( void *Cargo, int argc, char **argv, char **azColName ) hb_itemRelease( pArrayValue ); hb_itemRelease( pArrayColName ); + hb_vmRequestRestore(); + return iRes; } @@ -287,7 +289,7 @@ static int authorizer( void *Cargo, int iAction, const char *sName1, const char { PHB_DYNS pSym = ( PHB_DYNS ) Cargo; - if( pSym ) + if( pSym && hb_vmRequestReenter() ) { int iRes; PHB_ITEM pItem1 = hb_itemPutCConst( NULL, sName1 ); @@ -311,6 +313,8 @@ static int authorizer( void *Cargo, int iAction, const char *sName1, const char hb_itemRelease( pItem3 ); hb_itemRelease( pItem4 ); + hb_vmRequestRestore(); + return iRes; } @@ -321,7 +325,7 @@ static int busy_handler( void *Cargo, int iNumberOfTimes ) { PHB_DYNS pSym = ( PHB_DYNS ) Cargo; - if( pSym ) + if( pSym && hb_vmRequestReenter() ) { int iRes; @@ -332,6 +336,8 @@ static int busy_handler( void *Cargo, int iNumberOfTimes ) iRes = hb_parni( -1 ); + hb_vmRequestRestore(); + return iRes; } @@ -342,7 +348,7 @@ static int progress_handler( void *Cargo ) { PHB_DYNS pSym = ( PHB_DYNS ) Cargo; - if( pSym ) + if( pSym && hb_vmRequestReenter() ) { int iRes; @@ -352,6 +358,8 @@ static int progress_handler( void *Cargo ) iRes = hb_parni( -1 ); + hb_vmRequestRestore(); + return iRes; } @@ -362,7 +370,7 @@ static int hook_commit( void *Cargo ) { PHB_DYNS pSym = ( PHB_DYNS ) Cargo; - if( pSym ) + if( pSym && hb_vmRequestReenter() ) { int iRes; @@ -372,6 +380,8 @@ static int hook_commit( void *Cargo ) iRes = hb_parni( -1 ); + hb_vmRequestRestore(); + return iRes; } @@ -382,11 +392,13 @@ static void hook_rollback( void *Cargo ) { PHB_DYNS pSym = ( PHB_DYNS ) Cargo; - if( pSym ) + if( pSym && hb_vmRequestReenter() ) { hb_vmPushDynSym( pSym ); hb_vmPushNil(); hb_vmDo( 0 ); + + hb_vmRequestRestore(); } }