diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0ad7061c64..10a10bb1f3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,19 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-03 21:19 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbqt/hbqt_hbevents.cpp + * contrib/hbqt/hbqt_hbslots.cpp + - Deleted old method of slots/events handling. + + * contrib/hbide/idethemes.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/hbide.prg + * contrib/hbide/idemisc.prg + * contrib/hbide/idesaveload.prg + % Using hb_FileExists() instead of File(). + ! Fixed to not force lowercase on filenames. + 2010-01-03 11:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbxbp/xbpbrowse.prg * contrib/hbxbp/xbpwindow.prg diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 86a3c2b86c..9f1c35e9dc 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -674,7 +674,7 @@ METHOD HbIde:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme ) RETURN Self ENDIF - IF !Empty( cSourceFile ) .AND. !File( cSourceFile ) + IF !Empty( cSourceFile ) .AND. !hb_FileExists( cSourceFile ) MsgBox( 'File not found: ' + cSourceFile ) RETURN Self ENDIF @@ -1078,7 +1078,7 @@ METHOD HbIde:appendProjectInTree( aPrj ) aSrc := aPrj[ PRJ_PRP_SOURCES, 2 ] FOR j := 1 TO len( aSrc ) hb_fNameSplit( aSrc[ j ], @cPath, @cFile, @cExt ) - cPathA := lower( strtran( cPath, "\", "/" ) ) + cPathA := strtran( cPath, "\", "/" ) IF ( nPath := ascan( aPath, {|e_| e_[ 1 ] == cPathA } ) ) == 0 oPP := oParent:addItem( cPath ) aadd( ::aProjData, { oPP, "Path", oParent, cPathA, cProject } ) @@ -1424,7 +1424,7 @@ METHOD HbIde:loadUI( cUi ) LOCAL cUiFull := s_resPath + cUi + ".ui" LOCAL qDialog, qUiLoader, qFile - IF file( cUiFull ) + IF hb_FileExists( cUiFull ) qFile := QFile():new( cUiFull ) IF qFile:open( 1 ) qUiLoader := QUiLoader():new() @@ -1487,7 +1487,7 @@ METHOD HbIde:loadProjectProperties( cProject, lNew, lFetch, lUpdateTree ) IF lFetch ::cSaveTo := "" ::fetchProjectProperties() - IF !empty( ::cSaveTo ) .and. file( ::cSaveTo ) + IF !empty( ::cSaveTo ) .and. hb_FileExists( ::cSaveTo ) cProject := ::cSaveTo /* Reload from file */ ::aPrjProps := fetchHbiStructFromFile( cProject ) @@ -1977,7 +1977,7 @@ METHOD HbIde:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt ) IF ( nResult == 0 ) .AND. ( lLaunch ) cTmp += CRLF - IF !File( cTargetFN ) + IF !hb_FileExists( cTargetFN ) cTmp += "Launch application error: file not found " + cTargetFN + "!" ELSEIF aPrj[ PRJ_PRP_PROPERTIES, 2, E_qPrjType ] == "Executable" @@ -2004,7 +2004,7 @@ METHOD HbIde:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt ) FErase( cHbpPath ) ENDIF - IF lPPO .AND. File( cFileName ) + IF lPPO .AND. hb_FileExists( cFileName ) ::aEdits[ 1 ]:showPPO( cFileName ) ENDIF diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index ba8f78607e..d78cd9f1ae 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -425,7 +425,7 @@ METHOD IdeEditor:setTabImage() METHOD IdeEditor:showPPO( cFile ) LOCAL qEdit, qHiliter - IF file( cFile ) + IF hb_FileExists( cFile ) qEdit := QPlainTextEdit():new() qEdit:setPlainText( hb_memoRead( cFile ) ) qEdit:setLineWrapMode( QTextEdit_NoWrap ) diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index db3651a9c6..091a8eab1e 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -143,7 +143,7 @@ FUNCTION CreateTarget( cFile, txt_ ) fClose( hHandle ) ENDIF - RETURN file( cFile ) + RETURN hb_FileExists( cFile ) /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/idesaveload.prg b/harbour/contrib/hbide/idesaveload.prg index 3025e1b2d2..708877ec70 100644 --- a/harbour/contrib/hbide/idesaveload.prg +++ b/harbour/contrib/hbide/idesaveload.prg @@ -189,14 +189,9 @@ FUNCTION loadINI( oIde, cHbideIni ) DEFAULT cHbideIni TO "hbide.ini" - cHbideIni := lower( cHbideIni ) lValid := .F. - IF !file( cHbideIni ) - cHbideIni := hb_dirBase() + "hbide.ini" - ENDIF - - IF !file( cHbideIni ) + IF ! hb_FileExists( cHbideIni ) cHbideIni := hb_dirBase() + "hbide.ini" ENDIF @@ -209,7 +204,7 @@ FUNCTION loadINI( oIde, cHbideIni ) oIde:aIni[n] := Array(0) NEXT - IF file( oIde:cProjIni ) + IF hb_FileExists( oIde:cProjIni ) aElem := ReadSource( oIde:cProjIni ) FOR EACH s IN aElem diff --git a/harbour/contrib/hbide/idethemes.prg b/harbour/contrib/hbide/idethemes.prg index cd71ff71c9..cf64b5dec8 100644 --- a/harbour/contrib/hbide/idethemes.prg +++ b/harbour/contrib/hbide/idethemes.prg @@ -230,7 +230,7 @@ METHOD IdeThemes:contains( cTheme ) METHOD IdeThemes:load( cFile ) - IF hb_isChar( cFile ) .AND. !empty( cFile ) .AND. file( cFile ) + IF hb_isChar( cFile ) .AND. !empty( cFile ) .AND. hb_FileExists( cFile ) ::aIni:= ReadSource( cFile ) ::parseINI() ::lDefault := .f. @@ -262,7 +262,7 @@ METHOD IdeThemes:save( lAsk ) IF !empty( cFile ) cINI := ::buildINI() hb_memowrit( cFile, cINI ) - IF file( cFile ) + IF hb_FileExists( cFile ) ::oIde:cIniThemes := cFile ::cIniFile := cFile ENDIF diff --git a/harbour/contrib/hbqt/hbqt_hbevents.cpp b/harbour/contrib/hbqt/hbqt_hbevents.cpp index ba0057928e..e0acc094c3 100644 --- a/harbour/contrib/hbqt/hbqt_hbevents.cpp +++ b/harbour/contrib/hbqt/hbqt_hbevents.cpp @@ -7,8 +7,8 @@ * QT wrapper main header * * Copyright 2009 Marcos Antonio Gambeta - * * Copyright 2009 Pritpal Bedi + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -64,107 +64,6 @@ #include "hbqt_hbevents.h" -#include - -/*----------------------------------------------------------------------*/ - -typedef struct -{ - HBEvents * t_events; -} HB_EVENTS, * PHB_EVENTS; - -static HB_TSD_NEW( s_events, sizeof( HB_EVENTS ), NULL, NULL ); - -#define HB_QTTHREAD_EVENTS() ( ( PHB_EVENTS ) hb_stackGetTSD( &s_events ) ) - -/*----------------------------------------------------------------------*/ - -static HBEvents * qt_getEventFilter( void ) -{ - PHB_EVENTS p_events = HB_QTTHREAD_EVENTS(); - - if( ! p_events->t_events ) - p_events->t_events = new HBEvents(); - - return p_events->t_events; -} - -/* TOFIX: Possible GPF is below pointer is used by .prg after release. */ -HB_FUNC( QT_GETEVENTFILTER ) -{ - hb_retptr( qt_getEventFilter() ); -} - -/* TOFIX: Leak if .prg code doesn't call this explicitly. */ -HB_FUNC( QT_EVENTS_DESTROY ) -{ - PHB_EVENTS p_events = HB_QTTHREAD_EVENTS(); - - if( p_events->t_events ) - { - p_events->t_events->~HBEvents(); - p_events->t_events = NULL; - } -} - -/*----------------------------------------------------------------------*/ - -HB_FUNC( QT_CONNECT_EVENT ) -{ - QObject * object = ( QObject* ) hbqt_pPtrFromObj( 1 ); /* get sender */ - - if( object ) - { - int type = hb_parni( 2 ); - PHB_ITEM codeblock = hb_itemNew( hb_param( 3, HB_IT_BLOCK | HB_IT_BYREF ) ); - HBEvents * t_events = qt_getEventFilter(); - - char prop[ 20 ]; - 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() ); - - hb_retl( HB_TRUE ); - } - else - hb_retl( HB_FALSE ); -} - -HB_FUNC( QT_DISCONNECT_EVENT ) -{ - HB_BOOL bRet = HB_FALSE; - QObject * object = ( QObject* ) hbqt_pPtrFromObj( 1 ); - - if( object ) - { - int type = hb_parni( 2 ); - HBEvents * t_events = qt_getEventFilter(); - - char prop[ 20 ]; - hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", type, "P" ); /* Make it a unique identifier */ - - int i = object->property( prop ).toInt(); - if( i > 0 && i <= t_events->listBlock.size() ) - { - hb_itemRelease( t_events->listBlock.at( i - 1 ) ); - t_events->listBlock[ i - 1 ] = NULL; - t_events->listObj[ i - 1 ] = NULL; - object->setProperty( prop, QVariant() ); - bRet = HB_TRUE; - - HB_TRACE( HB_TR_DEBUG, ( " QT_DISCONNECT_EVENT: %i", type ) ); - } - } - - hb_retl( bRet ); -} - -/*----------------------------------------------------------------------*/ - #include #include @@ -226,14 +125,6 @@ static void * hbqt_gcAllocate_HBEvents( void * pObj ) /*----------------------------------------------------------------------*/ -/* TOFIX: Possible GPF is below pointer is used by .prg after release. */ -HB_FUNC( QT_EVENTS_PTR ) -{ - hb_retptr( hbqt_par_HBEvents( 1 ) ); -} - -/*----------------------------------------------------------------------*/ - HBEvents::HBEvents( QObject * parent ) : QObject( parent ) { } diff --git a/harbour/contrib/hbqt/hbqt_hbslots.cpp b/harbour/contrib/hbqt/hbqt_hbslots.cpp index fe285d2f66..74da801460 100644 --- a/harbour/contrib/hbqt/hbqt_hbslots.cpp +++ b/harbour/contrib/hbqt/hbqt_hbslots.cpp @@ -7,8 +7,8 @@ * QT wrapper main header * * Copyright 2009 Marcos Antonio Gambeta - * * Copyright 2009 Pritpal Bedi + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -64,41 +64,10 @@ #include "hbqt_hbslots.h" -/*----------------------------------------------------------------------*/ - -typedef struct -{ - HBSlots * t_slots; -} HB_SLOTS, * PHB_SLOTS; - -static HB_TSD_NEW( s_slots, sizeof( HB_SLOTS ), NULL, NULL ); - -#define HB_QTTHREAD_SLOTS() ( ( PHB_SLOTS ) hb_stackGetTSD( &s_slots ) ) +#include /*----------------------------------------------------------------------*/ -static HBSlots * qt_getEventSlots( void ) -{ - PHB_SLOTS p_slots = HB_QTTHREAD_SLOTS(); - - if( ! p_slots->t_slots ) - p_slots->t_slots = new HBSlots(); - - return p_slots->t_slots; -} - -/* TOFIX: Leak if .prg code doesn't call this explicitly. */ -HB_FUNC( QT_SLOTS_DESTROY ) -{ - PHB_SLOTS p_slots = HB_QTTHREAD_SLOTS(); - - if( p_slots->t_slots ) - { - p_slots->t_slots->~HBSlots(); - p_slots->t_slots = NULL; - } -} - static bool connect_signal( QString signal, QObject * object, HBSlots * t_slots ) { bool ret; @@ -351,62 +320,6 @@ static bool disconnect_signal( QObject * object, const char * signal ) } /*----------------------------------------------------------------------*/ -/* - * Harbour function to connect signals with slots - */ -HB_FUNC( QT_CONNECT_SIGNAL ) -{ - QObject * object = ( QObject * ) hbqt_pPtrFromObj( 1 ); /* get sender */ - - if( object ) - { - QString signal = hb_parcx( 2 ); /* get signal */ - HBSlots * t_slots = qt_getEventSlots(); - - if( connect_signal( signal, object, t_slots ) ) - { - PHB_ITEM pBlock = hb_itemNew( hb_param( 3, HB_IT_BLOCK ) ); /* get codeblock */ - t_slots->listBlock << pBlock; - object->setProperty( hb_parcx( 2 ), ( int ) t_slots->listBlock.size() ); - hb_retl( HB_TRUE ); - } - else - hb_retl( HB_FALSE ); - } - else - hb_retl( HB_FALSE ); -} - -/* - * harbour function to disconnect signals - */ -HB_FUNC( QT_DISCONNECT_SIGNAL ) -{ - QObject * object = ( QObject* ) hbqt_pPtrFromObj( 1 ); - bool bFreed = false; - - if( object ) - { - HBSlots * t_slots = qt_getEventSlots(); - const char * signal = hb_parcx( 2 ); - int i = object->property( signal ).toInt(); - - if( i > 0 && i <= t_slots->listBlock.size() ) - { - hb_itemRelease( t_slots->listBlock.at( i - 1 ) ); - t_slots->listBlock[ i - 1 ] = NULL; - - bFreed = disconnect_signal( object, signal ); - - //HB_TRACE( HB_TR_DEBUG, ( " QT_DISCONNECT_SIGNAL: %s %s", bFreed ? "YES" : "NO", signal ) ); - } - } - hb_retl( bFreed ); -} - -/*----------------------------------------------------------------------*/ - -#include typedef struct {