From kde-devel Sun Apr 07 17:10:48 2002 From: Patrick Julien Date: Sun, 07 Apr 2002 17:10:48 +0000 To: kde-devel Subject: Re: QThread C++ X-MARC-Message: https://marc.info/?l=kde-devel&m=101821415820848 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 > >#include > > > 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 << >>> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<