shopsuite-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ShopSuite-dev] Re: QThread C++


From: Patrick Julien
Subject: [ShopSuite-dev] Re: QThread C++
Date: Sun, 07 Apr 2002 17:10:48 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020311

your thread object goes out of scope...

The "pure virtual method called" is the error message produced by gcc when you call a virtual method on a delete object.


Davi Leal wrote:

I have a QThread + QApplication 'main()' which crash 40% times. The output of the crash is:

$ ./shopsuite
Connected to the data base: shop
Listening products: shop
pure virtual method called  <----
Aborted                     <----
$


See below. If I uncomment the poolDB.wait() line the application never crash, however only when the QThread finish the application follows executing up to the "return app.exec()" event loop.

Maybe, is it due to I use the QApplication object. Must I convert the QApplication process into a second QThread to avoid the crash?. Any idea?.


int main(int argc, char* argv[])
{
        QApplication app( argc, argv );
        [...]
                         PoolDB poolDB;
                         poolDB.start();
                         /* poolDB.wait();  COMMENTED <------------*/
        
                        break; // Go out to the normal event loop 'app.exec()'
                }
        }

        return app.exec();
}



---
Qt 2.3.1
        ii  libqt2         2.3.1-22       Qt GUI Library (runtime version).
        ii  libqt2-mt      2.3.1-22       Qt GUI Library (runtime threaded 
version).    
Postgres 7.2.1

c++ -DQT_THREAD_SUPPORT c++ -Wall -g -O2 -lqt-mt
Debian GNU/Linux 'sid'













--
The below example from Qt 2.3 doc works rightly:


#include <qapplication.h>

#include <qthread.h>


class MyThread : public QThread {

 public:

   virtual void run();

 };

 void MyThread::run()
 {
   for(int count=0;count<20;count++) {
     sleep(1);
     qDebug("Ping!");
   }
 }

 int main()
 {
     MyThread a;
     MyThread b;
     a.start();
     b.start();
     a.wait();
     b.wait();
 }

g++ -DQT_THREAD_SUPPORT -Wall -O2 -o test test.cpp -I/usr/include/qt/ -lqt-mt


Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<






reply via email to

[Prev in Thread] Current Thread [Next in Thread]