void AiMainWindow::serialize (  )  [private, slot]

serialize threads saving storing it, for another usage =)

Definition at line 578 of file aimainwindow.cpp.

00579 {
00580     try
00581     {
00582         //check if threads is running
00583         if( m_threads.size() > 0 )
00584         {
00585             if( m_threads[ 0 ]->isRunning() )
00586             {
00587                 if( QMessageBox::Yes != QMessageBox::warning(this, tr("Serialization...") , tr("GOD MODE stop all current threads, you want continue?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) )
00588                 {
00589                     return;
00590                 }
00591                 else
00592                 {
00593                     //# magic bool
00594                     m_serialize = true;
00595                     //#
00596 
00597                     // stoping current threads
00598                     for( int index = 0 ; index < m_threads.size() ; index++ )
00599                     {
00600                         m_threads[ index ]->stop();
00601                         m_threads[ index ]->wait();
00602                     }
00603 
00604                 }
00605             }
00606         }
00607         else
00608         {
00609             QMessageBox::warning(this, tr("Threads"), tr("No threads for using 'GOD MODE' =)!"), QMessageBox::Ok) ;
00610             return;
00611         }
00612 
00613         //get file to save serialisation
00614         QString toFile = QFileDialog::getSaveFileName(this, tr("Serialization"), "", tr("File (*.adrabi)")) ;
00615         if( !toFile.isNull() && !toFile.isEmpty() )
00616         {
00617             QFile file( toFile );
00618             file.open(QIODevice::WriteOnly);
00619 
00620             //serializing (hmm.. maybe as TCP-Packets with header and data)
00621                 //# Header
00622             QDataStream stream( &file );
00623             stream.setVersion(QDataStream::Qt_4_6);
00624             stream  << QTime::currentTime()
00625                     << QDate::currentDate()
00626                     << (m_threads.count());
00627 
00628                 //# Data
00629 
00630             for( int x = 0 ; x < m_threads.count() ; x++ )
00631             {
00632                 AiZone * zone = m_threads[ x ]->getZone();
00633                 zone->serialize( stream );
00634 
00635             }
00636         }
00637 
00638         if( QMessageBox::Yes != QMessageBox::warning(this, tr("Threads...") , tr("You want clean all threads now?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) )
00639         {
00640             return;
00641         }
00642 
00643         //~ delete them all
00644         for( int index = 0 ; index < m_threads.size() ; index++ )
00645         {
00646             delete m_threads[ index ];
00647         }
00648         m_threads.clear();
00649     }
00650     catch(const std::exception & exception )
00651     {
00652         QMessageBox::critical(this, tr("Critical Error!"), tr("Please report this problem to adrabi[at]gmail[dot]com =)."));
00653     }
00654 }

 All Classes Namespaces Files Functions Variables Typedefs

Generated on Sat Feb 27 08:33:18 2010 for AiFractals by  doxygen 1.6.1