void InquireServersGUI::setPixmap( QPixmap pix )
{
- if ( !pix.isNull() ) {
+ if ( !pix.isNull() )
+ {
mySplash->setPixmap( pix );
int w = mySplash->sizeHint().width() + MARGIN_SIZE*2;
myPrgBar->setFixedWidth( w );
InquireServersGUI::~InquireServersGUI()
{
- // Thread deletes itself in the end of run() function
delete myThread;
}
//=================================================================================
void InquireServersGUI::ClickOnCancel()
{
- //it's necessary to stop asking servers
- myThread->stop();
- // myGUI = false;
- //Also we should send QCloseEvent in order to close this widget (and remove from screen)
- //QThread::postEvent ( this, new QCloseEvent() );
- qApp->exit(1);
-}
-
-void InquireServersGUI::closeEvent ( QCloseEvent * pe)
-{
- //default implementation calls e->accept(), which hides this widget.
- //See the QCloseEvent documentation for more details.
- pe->accept();
- QApplication::flushX ();
- QApplication::syncX ();
- qApp->exit();
+ myThread->stop(); //it's necessary to stop asking servers
+ hide();
+ qApp->exit( 1 );
}
void InquireServersGUI::customEvent( QCustomEvent* pe )
while ( IsChecking && receiver )
{
for (int i=1; i<=8; i++)
+ {
+ if ( myMessages[i-1].isEmpty() )
{
- if ( myMessages[i-1].isEmpty() ) {
- 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;
- }
- QString *message = new QString(myMessages[i-1]);
- QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEventLabel, message ) );
- QThread::usleep(200000);
- QString *errMsg;
- bool result = AskServer(i,&errMsg);
- if (result)
- {
- QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEvent, new int( i ) ) );
- 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;
- }
- }
+ if ( i==8 )
+ {
+ IsChecking = false;
+ myExitStatus = 0; //myExitStatus should be 0 because all servers exist and work
+ sleep( 1 ); // sleep( 1 second ) in order to see 100%. in other case it closes on 85%..
+ break;
+ }
else
- {
- QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEventError, errMsg ) );
- //myExitStatus should be 1 because we didn't receive response from server
- myExitStatus = 1;
- return;
- }
+ continue;
}
+ QString *message = new QString(myMessages[i-1]);
+ QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEventLabel, message ) );
+ QThread::usleep(200000);
+ QString *errMsg;
+ bool result = AskServer(i,&errMsg);
+ if (result)
+ {
+ QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEvent, new int( i ) ) );
+ if ( i==8 )
+ {
+ IsChecking = false;
+ myExitStatus = 0; //myExitStatus should be 0 because all servers exist and work
+ sleep( 1 ); // sleep( 1 second ) in order to see 100%. in other case it closes on 85%..
+ break;
+ }
+ }
+ else
+ {
+ QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEventError, errMsg ) );
+ stop();
+ break;
+ }
+ }
}
- // this outputs WARNING: QThread object is deleted while still running -- it's OK in our case!
- //delete this;
+ receiver->hide();
+ qApp->exit( myExitStatus );
+}
+
+void InquireServersQThread::stop()
+{
+ IsChecking = false;
+ myExitStatus = 1;
}
InquireServersQThread::~InquireServersQThread()
}
return result;
}
+