From: asv Date: Fri, 24 Jun 2005 07:02:19 +0000 (+0000) Subject: Bugs with warnings (unexpected NULL receiver) are fixed. X-Git-Tag: T3_0_0_a4~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6e0c02419b908dde2e391d544284332dfbf2e6e8;p=modules%2Fgui.git Bugs with warnings (unexpected NULL receiver) are fixed. --- diff --git a/src/Session/InquireServersQThread.cxx b/src/Session/InquireServersQThread.cxx index 00bc1dab7..a3edf53a6 100755 --- a/src/Session/InquireServersQThread.cxx +++ b/src/Session/InquireServersQThread.cxx @@ -10,7 +10,7 @@ using namespace std; #include "InquireServersQThread.h" -#include +#include #include #include #include @@ -129,6 +129,7 @@ void InquireServersGUI::setPixmap( QPixmap pix ) InquireServersGUI::~InquireServersGUI() { + // Thread deletes itself in the end of run() function delete myThread; } @@ -252,22 +253,20 @@ InquireServersQThread::InquireServersQThread( InquireServersGUI* r ) void InquireServersQThread::run() { - while (IsChecking) + while ( IsChecking && receiver ) { - if ( !receiver ) - { - myExitStatus = 0; - return; - } for (int i=1; i<=8; i++) { if ( myMessages[i-1].isEmpty() ) { - if (i==8) { + if ( i==8 ) { IsChecking = false; //myExitStatus should be 0 because all servers exist and work myExitStatus = 0; //we should send QCloseEvent in order to close this widget (and remove from screen) + qApp->processEvents(); + sleep( 1 ); // sleep( 1 second ) in order to see 100%. in other case it closes on 85%.. QThread::postEvent ( receiver , new QCloseEvent() ); + break; } else continue; } @@ -279,13 +278,16 @@ void InquireServersQThread::run() if (result) { QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEvent, new int( i ) ) ); - if (i==8) + if ( i==8 ) { IsChecking = false; //myExitStatus should be 0 because all servers exist and work myExitStatus = 0; - //we should send QCloseEvent in order to close this widget (and remove from screen) + //we should send QCloseEvent in order to close this widget (and remove from screen) + qApp->processEvents(); + sleep( 1 ); // sleep( 1 second ) in order to see 100%. in other case it closes on 85%.. QThread::postEvent ( receiver , new QCloseEvent() ); + break; } } else @@ -297,6 +299,13 @@ void InquireServersQThread::run() } } } + + // this outputs WARNING: QThread object is deleted while still running -- it's OK in our case! + //delete this; +} + +InquireServersQThread::~InquireServersQThread() +{ } bool InquireServersQThread::AskServer(int iteration, QString ** errMessage) diff --git a/src/Session/InquireServersQThread.h b/src/Session/InquireServersQThread.h index 37b32cd62..ef08ace7d 100755 --- a/src/Session/InquireServersQThread.h +++ b/src/Session/InquireServersQThread.h @@ -7,11 +7,11 @@ // Module : SALOME // $Header$ -#include #include #include #include #include +#include /********************************************************** ** Class: InquireEvent @@ -40,6 +40,7 @@ class InquireServersQThread : public QThread { public: InquireServersQThread( InquireServersGUI* r ); + virtual ~InquireServersQThread(); //the main loop of this thread virtual void run() ; @@ -63,7 +64,7 @@ private: //variables: - InquireServersGUI* receiver; + QGuardedPtr receiver; int _argc ; char ** _argv; //this variable is true if we are checking servers