From a40c2a6975f6496faac89031fd26d0f45d446584 Mon Sep 17 00:00:00 2001 From: mkr Date: Thu, 24 May 2007 07:10:37 +0000 Subject: [PATCH] Porting to Qt4. --- src/DDS/DDS.pro | 2 +- src/Event/Event.pro | 26 +++++++++++++++ src/Event/SALOME_Event.cxx | 44 ++++++++++++++++++------- src/Event/SALOME_Event.hxx | 25 +++++++++++++-- src/Makefile.am | 4 +-- src/OBJECT/OBJECT.pro | 66 ++++++++++++++++++++++++++++++++++++++ src/src.pro | 2 ++ 7 files changed, 151 insertions(+), 18 deletions(-) create mode 100644 src/Event/Event.pro create mode 100644 src/OBJECT/OBJECT.pro diff --git a/src/DDS/DDS.pro b/src/DDS/DDS.pro index 96434e96d..f4d677c45 100644 --- a/src/DDS/DDS.pro +++ b/src/DDS/DDS.pro @@ -18,7 +18,7 @@ CONFIG -= debug release debug_and_release CONFIG += qt thread debug dll shared win32:DEFINES += WIN32 -DEFINES += DDS_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS +DEFINES += OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS HEADERS = DDS.h HEADERS += DDS_DicGroup.h diff --git a/src/Event/Event.pro b/src/Event/Event.pro new file mode 100644 index 000000000..4361449c1 --- /dev/null +++ b/src/Event/Event.pro @@ -0,0 +1,26 @@ +TEMPLATE = lib +TARGET = Event +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +KERNEL_CXXFLAGS = $$(KERNEL_ROOT_DIR)/include/salome + +INCLUDEPATH += ../../include $${KERNEL_CXXFLAGS} +LIBS += + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += EVENT_EXPORTS + +HEADERS = Event.h +HEADERS += SALOME_Event.hxx + +SOURCES = SALOME_Event.cxx + +includes.files = $$HEADERS +includes.path = ../../include + +INSTALLS += includes diff --git a/src/Event/SALOME_Event.cxx b/src/Event/SALOME_Event.cxx index 928cd2341..f50cdc9c4 100755 --- a/src/Event/SALOME_Event.cxx +++ b/src/Event/SALOME_Event.cxx @@ -30,9 +30,8 @@ //#include "utilities.h" -#include -#include -#include +#include +#include // asv 21.02.05 : introducing multi-platform approach of thread comparison // on Unix using pthread_t type for storing ThreadId @@ -45,12 +44,33 @@ static DWORD myThread; #else -#include #include static pthread_t myThread; #endif +SALOME_CustomEvent::SALOME_CustomEvent( int type ) + : QEvent( (QEvent::Type)type ), d( 0 ) +{ +} + +SALOME_CustomEvent::SALOME_CustomEvent( QEvent::Type type, void *data ) + : QEvent( type ), d( data ) +{ +} + +void * SALOME_CustomEvent::data() const +{ + return d; +} + +void SALOME_CustomEvent::setData( void* data ) +{ + d = data; +} + +const int NumberOfResources = 2; + /*! \return thread id */ @@ -83,8 +103,8 @@ bool SALOME_Event::IsSessionThread(){ SALOME_Event::SALOME_Event(){ // if(MYDEBUG) MESSAGE( "SALOME_Event::SALOME_Event(): this = "<acquire( NumberOfResources ); } /*! @@ -92,8 +112,8 @@ SALOME_Event::SALOME_Event(){ */ SALOME_Event::~SALOME_Event(){ // if(MYDEBUG) MESSAGE( "SALOME_Event::~SALOME_Event(): this = "<available() < mySemaphore->total() ) - *mySemaphore -= mySemaphore->total() - mySemaphore->available(); + if ( mySemaphore->available() < NumberOfResources ) + mySemaphore->release( NumberOfResources - mySemaphore->available() ); delete mySemaphore; } @@ -102,9 +122,9 @@ SALOME_Event::~SALOME_Event(){ */ void SALOME_Event::process() { - QThread::postEvent( qApp, new QCustomEvent( SALOME_EVENT, (void*)this ) ); -// if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<acquire( 1 )" ); + mySemaphore->acquire( 1 ); // if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<