From 32bf41944d542a69c39b62fc643d8994225b8581 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 11 Dec 2009 10:01:12 +0000 Subject: [PATCH] 2009-12-11 10:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * include/hbextern.ch + Added HB_THREADONCEINIT(). * contrib/hbqt/hbqt.ch * contrib/hbxbp/xbp.ch ! Moved XBP specific macro to HBXBP header. * contrib/hbqt/tests/demoqt.prg ! Deleted no more needed init calls. * contrib/hbqt/hbqt_events.cpp + Added TOFIX about GC collected pointer stored in low level structure. (source of GPF). * contrib/hbwin/win_misc.c * contrib/hbwin/wapi_winbase.c * contrib/hbwin/wapi_winuser.c * contrib/hbwin/win_regc.c * contrib/hbwin/win_prn1.c * contrib/hbwin/win_prn3.c * contrib/hbwin/wapi_shellapi.c * contrib/hbwin/legacyco.c - Deleted now unnecessary '( LP[C]TSTR )' casts. + Cleaned const usage in WIN_PRINTERSETDEFAULT(). F.e. OpenPrinter() has apparently wrong winapi declaration, so a cast must have been added. ; TOFIX: CreateProcessW() second parameter has to be a read/write buffer. Przemek, do you have an idea how to solve that the cleanest way? (for now I kept a cast, assuming that a buffer is created by Harbour conversion API, but that's not something it guarantees in the future.) --- harbour/ChangeLog | 35 +++++++++++++++++++++++++++ harbour/contrib/hbqt/hbqt.ch | 3 +-- harbour/contrib/hbqt/hbqt_events.cpp | 1 + harbour/contrib/hbqt/tests/demoqt.prg | 3 --- harbour/contrib/hbwin/legacyco.c | 2 +- harbour/contrib/hbwin/wapi_shellapi.c | 8 +++--- harbour/contrib/hbwin/wapi_winbase.c | 8 +++--- harbour/contrib/hbwin/wapi_winuser.c | 8 +++--- harbour/contrib/hbwin/win_misc.c | 7 +++--- harbour/contrib/hbwin/win_prn1.c | 2 +- harbour/contrib/hbwin/win_prn3.c | 10 ++++---- harbour/contrib/hbwin/win_regc.c | 8 +++--- harbour/contrib/hbxbp/xbp.ch | 2 ++ harbour/include/hbextern.ch | 1 + 14 files changed, 67 insertions(+), 31 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b75f9ed171..2de1f77ff1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,41 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-11 10:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * include/hbextern.ch + + Added HB_THREADONCEINIT(). + + * contrib/hbqt/hbqt.ch + * contrib/hbxbp/xbp.ch + ! Moved XBP specific macro to HBXBP header. + + * contrib/hbqt/tests/demoqt.prg + ! Deleted no more needed init calls. + + * contrib/hbqt/hbqt_events.cpp + + Added TOFIX about GC collected pointer stored in low level + structure. (source of GPF). + + * contrib/hbwin/win_misc.c + * contrib/hbwin/wapi_winbase.c + * contrib/hbwin/wapi_winuser.c + * contrib/hbwin/win_regc.c + * contrib/hbwin/win_prn1.c + * contrib/hbwin/win_prn3.c + * contrib/hbwin/wapi_shellapi.c + * contrib/hbwin/legacyco.c + - Deleted now unnecessary '( LP[C]TSTR )' casts. + + Cleaned const usage in WIN_PRINTERSETDEFAULT(). + F.e. OpenPrinter() has apparently wrong winapi declaration, + so a cast must have been added. + + ; TOFIX: CreateProcessW() second parameter has to be a read/write + buffer. Przemek, do you have an idea how to solve that + the cleanest way? + (for now I kept a cast, assuming that a buffer is + created by Harbour conversion API, but that's not + something it guarantees in the future.) + 2009-12-11 04:37 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/thread.c ! added missing HB_STACK_TLS_PRELOAD diff --git a/harbour/contrib/hbqt/hbqt.ch b/harbour/contrib/hbqt/hbqt.ch index db4c22c54f..322cb2a696 100644 --- a/harbour/contrib/hbqt/hbqt.ch +++ b/harbour/contrib/hbqt/hbqt.ch @@ -73,8 +73,7 @@ #xtranslate HBQT_DEBUG( [] ) => iif( .T.,, ) #endif -#define QT_PTROF( oObj ) ( oObj:pPtr ) -#define QT_PTROFXBP( oXbp ) ( oXbp:oWidget:pPtr ) +#define QT_PTROF( oObj ) ( oObj:pPtr ) #define HBQT_RELEASE_WITH_DELETE 0 // Release the QObject with delete operator #define HBQT_RELEASE_WITH_DESTRUTOR 1 // Release the QObject with his destructor diff --git a/harbour/contrib/hbqt/hbqt_events.cpp b/harbour/contrib/hbqt/hbqt_events.cpp index e7fe820155..ec689f78d6 100644 --- a/harbour/contrib/hbqt/hbqt_events.cpp +++ b/harbour/contrib/hbqt/hbqt_events.cpp @@ -167,6 +167,7 @@ HB_FUNC( QT_CONNECT_EVENT ) hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", type, "P" ); /* Make it a unique identifier */ t_events->listBlock << codeblock; + /* TOFIX: Reference to GC collected pointer is stored. */ t_events->listObj << object; object->setProperty( prop, ( int ) t_events->listBlock.size() ); diff --git a/harbour/contrib/hbqt/tests/demoqt.prg b/harbour/contrib/hbqt/tests/demoqt.prg index 46bf5c5349..6c43212375 100644 --- a/harbour/contrib/hbqt/tests/demoqt.prg +++ b/harbour/contrib/hbqt/tests/demoqt.prg @@ -113,9 +113,6 @@ PROCEDURE Main() //LOCAL oStyle, oSize, n, aObj := array( nLoops ) //LOCAL nLoops := 500 - Qt_SetEventFilter() - Qt_SetEventSlots() - DO CASE CASE HbQt_Set_Release_Method() == HBQT_RELEASE_WITH_DELETE HBQT_DEBUG( "HbQt_Set_Release_Method DEFAULT : HBQT_RELEASE_WITH_DELETE" ) diff --git a/harbour/contrib/hbwin/legacyco.c b/harbour/contrib/hbwin/legacyco.c index fabef4ae08..ff1cd94cd4 100644 --- a/harbour/contrib/hbwin/legacyco.c +++ b/harbour/contrib/hbwin/legacyco.c @@ -117,7 +117,7 @@ HB_FUNC( MESSAGEBOX ) void * hStr2; HWND hWnd = HB_ISNUM( 1 ) ? ( HWND ) ( HB_PTRUINT ) hb_parnint( 1 ) : ( HWND ) hb_parptr( 1 ); - hb_retni( MessageBox( hWnd, ( LPCTSTR ) HB_PARSTR( 2, &hStr1, NULL ), ( LPCTSTR ) HB_PARSTR( 3, &hStr2, NULL ), hb_parni( 4 ) ) ); + hb_retni( MessageBox( hWnd, HB_PARSTR( 2, &hStr1, NULL ), HB_PARSTR( 3, &hStr2, NULL ), hb_parni( 4 ) ) ); hb_strfree( hStr1 ); hb_strfree( hStr2 ); } diff --git a/harbour/contrib/hbwin/wapi_shellapi.c b/harbour/contrib/hbwin/wapi_shellapi.c index 60863fe344..6ff5188c4e 100644 --- a/harbour/contrib/hbwin/wapi_shellapi.c +++ b/harbour/contrib/hbwin/wapi_shellapi.c @@ -68,10 +68,10 @@ HB_FUNC( WAPI_SHELLEXECUTE ) void * hDirectory; hb_retnint( ( HB_PTRDIFF ) ShellExecute( ( HWND ) hb_parptr( 1 ), - ( LPCTSTR ) HB_PARSTRDEF( 2, &hOperation , NULL ), /* edit, explore, open, print, play?, properties? */ - ( LPCTSTR ) HB_PARSTR( 3, &hFile , NULL ), - ( LPCTSTR ) HB_PARSTR( 4, &hParameters, NULL ), - ( LPCTSTR ) HB_PARSTR( 5, &hDirectory , NULL ), + HB_PARSTRDEF( 2, &hOperation , NULL ), /* edit, explore, open, print, play?, properties? */ + HB_PARSTR( 3, &hFile , NULL ), + HB_PARSTR( 4, &hParameters, NULL ), + HB_PARSTR( 5, &hDirectory , NULL ), HB_ISNUM( 6 ) ? hb_parni( 6 ) : SW_SHOWNORMAL /* nShowCmd */ ) ); hb_strfree( hOperation ); diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index 9eef89a0e9..540b43a3da 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -160,7 +160,7 @@ HB_FUNC( WAPI_LOADLIBRARY ) { void * hName; - hb_retptr( LoadLibrary( ( LPCTSTR ) HB_PARSTRDEF( 1, &hName, NULL ) ) ); + hb_retptr( LoadLibrary( HB_PARSTRDEF( 1, &hName, NULL ) ) ); hb_strfree( hName ); } @@ -184,7 +184,7 @@ HB_FUNC( WAPI_GETMODULEHANDLE ) { void * hModuleName; - wapi_ret_HANDLE( GetModuleHandle( ( LPCTSTR ) HB_PARSTR( 1, &hModuleName, NULL ) ) ); + wapi_ret_HANDLE( GetModuleHandle( HB_PARSTR( 1, &hModuleName, NULL ) ) ); hb_strfree( hModuleName ); } @@ -199,7 +199,7 @@ HB_FUNC( WAPI_OUTPUTDEBUGSTRING ) { void * hOutputString; - OutputDebugString( ( LPCTSTR ) HB_PARSTR( 1, &hOutputString, NULL ) ); + OutputDebugString( HB_PARSTR( 1, &hOutputString, NULL ) ); hb_strfree( hOutputString ); } @@ -213,7 +213,7 @@ HB_FUNC( WAPI_FORMATMESSAGE ) DWORD dwRetVal; hb_retnl( dwRetVal = FormatMessage( ( DWORD ) hb_parnldef( 1, FORMAT_MESSAGE_FROM_SYSTEM ) /* dwFlags */, - HB_ISCHAR( 2 ) ? ( LPCVOID ) HB_PARSTR( 2, &hSource, NULL ) : hb_parptr( 2 ), + HB_ISCHAR( 2 ) ? HB_PARSTR( 2, &hSource, NULL ) : hb_parptr( 2 ), HB_ISNUM( 3 ) ? ( DWORD ) hb_parnl( 3 ) : GetLastError() /* dwMessageId */, ( DWORD ) hb_parnldef( 4, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) ) /* dwLanguageId */, lpBuffer, diff --git a/harbour/contrib/hbwin/wapi_winuser.c b/harbour/contrib/hbwin/wapi_winuser.c index b03003ec30..9fd0889b6b 100644 --- a/harbour/contrib/hbwin/wapi_winuser.c +++ b/harbour/contrib/hbwin/wapi_winuser.c @@ -74,7 +74,7 @@ HB_FUNC( WAPI_MESSAGEBOX ) { void * hStr1; void * hStr2; - hb_retni( MessageBox( ( HWND ) hb_parptr( 1 ), ( LPCTSTR ) HB_PARSTR( 2, &hStr1, NULL ), ( LPCTSTR ) HB_PARSTR( 3, &hStr2, NULL ), hb_parni( 4 ) ) ); + hb_retni( MessageBox( ( HWND ) hb_parptr( 1 ), HB_PARSTR( 2, &hStr1, NULL ), HB_PARSTR( 3, &hStr2, NULL ), hb_parni( 4 ) ) ); hb_strfree( hStr1 ); hb_strfree( hStr2 ); } @@ -86,8 +86,8 @@ HB_FUNC( WAPI_CREATEWINDOWEX ) hb_retptr( CreateWindowEx( ( DWORD ) hb_parnl( 1 ) /* dwExStyle */, - ( LPCTSTR ) HB_PARSTRDEF( 2, &hClassName, NULL ), - ( LPCTSTR ) HB_PARSTRDEF( 3, &hWindowName, NULL ), + HB_PARSTRDEF( 2, &hClassName, NULL ), + HB_PARSTRDEF( 3, &hWindowName, NULL ), HB_ISNUM( 4 ) ? ( DWORD ) hb_parnl( 4 ) : WS_OVERLAPPEDWINDOW /* dwStyle */, HB_ISNUM( 5 ) ? ( int ) hb_parni( 5 ) : ( int ) CW_USEDEFAULT /* x */, HB_ISNUM( 6 ) ? ( int ) hb_parni( 6 ) : ( int ) CW_USEDEFAULT /* y */, @@ -307,7 +307,7 @@ HB_FUNC( WAPI_LOADBITMAP ) else { void * hBmp; - hb_retptr( LoadBitmap( wapi_par_HINSTANCE( 1 ), ( LPCTSTR ) HB_PARSTRDEF( 2, &hBmp, NULL ) ) ); + hb_retptr( LoadBitmap( wapi_par_HINSTANCE( 1 ), HB_PARSTRDEF( 2, &hBmp, NULL ) ) ); hb_strfree( hBmp ); } } diff --git a/harbour/contrib/hbwin/win_misc.c b/harbour/contrib/hbwin/win_misc.c index 378a75bf54..2698f8f17f 100644 --- a/harbour/contrib/hbwin/win_misc.c +++ b/harbour/contrib/hbwin/win_misc.c @@ -85,7 +85,8 @@ HB_FUNC( WIN_RUNDETACHED ) #endif if( CreateProcess( - ( LPCTSTR ) HB_PARSTR( 1, &hCommandName, NULL ), /* Command name */ + HB_PARSTR( 1, &hCommandName, NULL ), /* Command name */ + /* TOFIX */ ( LPTSTR ) HB_PARSTR( 2, &hCommandLine, NULL ), /* Command line (Unicode version needs an non-const buffer) */ NULL, /* Process handle not inheritable */ NULL, /* Thread handle not inheritable */ @@ -139,8 +140,8 @@ HB_FUNC( WIN_LOADRESOURCE ) void * hType; HRSRC hRes = FindResource( ( HMODULE ) hInstance, - ( LPCTSTR ) HB_PARSTRDEF( 1, &hName, NULL ), - ( LPCTSTR ) HB_PARSTRDEF( 2, &hType, NULL ) ); + HB_PARSTRDEF( 1, &hName, NULL ), + HB_PARSTRDEF( 2, &hType, NULL ) ); if( hRes ) { diff --git a/harbour/contrib/hbwin/win_prn1.c b/harbour/contrib/hbwin/win_prn1.c index 2f5cebfe2a..d0acf8d366 100644 --- a/harbour/contrib/hbwin/win_prn1.c +++ b/harbour/contrib/hbwin/win_prn1.c @@ -159,7 +159,7 @@ HB_FUNC( WIN_CREATEDC ) { void * hDevice; - HDC hDC = CreateDC( TEXT( "" ), ( LPCTSTR ) HB_PARSTR( 1, &hDevice, NULL ), NULL, NULL ); + HDC hDC = CreateDC( TEXT( "" ), HB_PARSTR( 1, &hDevice, NULL ), NULL, NULL ); if( hDC ) { diff --git a/harbour/contrib/hbwin/win_prn3.c b/harbour/contrib/hbwin/win_prn3.c index 3aeeff6737..23b05809a6 100644 --- a/harbour/contrib/hbwin/win_prn3.c +++ b/harbour/contrib/hbwin/win_prn3.c @@ -66,7 +66,7 @@ #include "hbapi.h" #include "hbwinuni.h" -static HB_BOOL hb_SetDefaultPrinter( LPTSTR lpPrinterName ) +static HB_BOOL hb_SetDefaultPrinter( LPCTSTR lpPrinterName ) { BOOL bFlag; OSVERSIONINFO osv; @@ -83,7 +83,7 @@ static HB_BOOL hb_SetDefaultPrinter( LPTSTR lpPrinterName ) if( osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { /* Open this printer so you can get information about it. */ - bFlag = OpenPrinter( lpPrinterName, &hPrinter, NULL ); + bFlag = OpenPrinter( ( LPTSTR ) lpPrinterName, &hPrinter, NULL ); if( ! bFlag || ! hPrinter ) return HB_FALSE; @@ -141,7 +141,7 @@ static HB_BOOL hb_SetDefaultPrinter( LPTSTR lpPrinterName ) if( osv.dwMajorVersion >= 5 ) /* Windows 2000 or later (use explicit call) */ { HMODULE hWinSpool; - typedef BOOL ( WINAPI * DEFPRINTER )( LPTSTR ); /* stops warnings */ + typedef BOOL ( WINAPI * DEFPRINTER )( LPCTSTR ); /* stops warnings */ DEFPRINTER fnSetDefaultPrinter; hWinSpool = LoadLibrary( TEXT( "winspool.drv" ) ); @@ -167,7 +167,7 @@ static HB_BOOL hb_SetDefaultPrinter( LPTSTR lpPrinterName ) else /* NT4.0 or earlier */ { /* Open this printer so you can get information about it. */ - bFlag = OpenPrinter( lpPrinterName, &hPrinter, NULL ); + bFlag = OpenPrinter( ( LPTSTR ) lpPrinterName, &hPrinter, NULL ); if( ! bFlag || ! hPrinter ) return HB_FALSE; @@ -254,7 +254,7 @@ HB_FUNC( WIN_PRINTERSETDEFAULT ) { void * hPrinterName; - hb_retl( hb_SetDefaultPrinter( ( LPTSTR ) HB_PARSTR( 1, &hPrinterName, NULL ) ) ); + hb_retl( hb_SetDefaultPrinter( HB_PARSTR( 1, &hPrinterName, NULL ) ) ); hb_strfree( hPrinterName ); } diff --git a/harbour/contrib/hbwin/win_regc.c b/harbour/contrib/hbwin/win_regc.c index b43cf33ea7..659cef13ec 100644 --- a/harbour/contrib/hbwin/win_regc.c +++ b/harbour/contrib/hbwin/win_regc.c @@ -86,7 +86,7 @@ HB_FUNC( WIN_REGCREATEKEYEX ) DWORD dwDisposition = 0; hb_retl( RegCreateKeyEx( hb_regkeyconv( ( HB_PTRUINT ) hb_parnint( 1 ) ), - ( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ), + HB_PARSTRDEF( 2, &hKey, NULL ), 0, NULL, hb_parnl( 5 ) /* dwOptions */, @@ -107,7 +107,7 @@ HB_FUNC( WIN_REGOPENKEYEX ) HKEY hkResult = NULL; hb_retl( RegOpenKeyEx( hb_regkeyconv( ( HB_PTRUINT ) hb_parnint( 1 ) ), - ( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ), + HB_PARSTRDEF( 2, &hKey, NULL ), 0 /* dwOptions */, hb_parnl( 4 ) /* samDesired */, &hkResult ) == ERROR_SUCCESS ); @@ -189,7 +189,7 @@ HB_FUNC( WIN_REGSETVALUEEX ) { DWORD nSpace = ( DWORD ) hb_parnl( 5 ); hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ), - ( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ), + HB_PARSTRDEF( 2, &hKey, NULL ), 0, dwType, ( BYTE * ) &nSpace, @@ -197,7 +197,7 @@ HB_FUNC( WIN_REGSETVALUEEX ) } else hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ), - ( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ), + HB_PARSTRDEF( 2, &hKey, NULL ), 0, dwType, ( BYTE * ) hb_parcx( 5 ) /* cValue */, diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index f3ab8a75a2..b4088bea27 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -10,6 +10,8 @@ #xtranslate HBXBP_DEBUG( [] ) => iif( .T.,, ) #endif +#define QT_PTROFXBP( oXbp ) ( oXbp:oWidget:pPtr ) + /*----------------------------------------------------------------------*/ #include "hbqt.ch" diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 4c2ef784d4..ba8f3b6d4a 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -1056,6 +1056,7 @@ EXTERNAL HB_THREADSTART EXTERNAL HB_THREADJOIN EXTERNAL HB_THREADDETACH EXTERNAL HB_THREADONCE +EXTERNAL HB_THREADONCEINIT EXTERNAL HB_THREADQUITREQUEST EXTERNAL HB_THREADWAIT EXTERNAL HB_THREADWAITFORALL