[Qt-interest] Debugger for Qt threaded applications

Miguel Cardenas mfcardenas at gmail.com
Mon Oct 12 16:45:07 CEST 2009


Hello

I need to debug a Linux Qt4 threaded application but have not a good tool.
My current debugger is kdgb that works for simple programs. I have a
threaded one that apparently works but randomly it causes segmentation fault
when a button launches a thread, somtimes works, sometimes crashes and don't
know where...

Is there a good graphic debugger that I can use to findout where is the
problem and be able to fix it?

Or perhaps you could give me an idea on what is going on... Normally the
first time I start the thread it works, but after 2 or 3 times it crashes.
Note that a single thread is launched, and the button that starts the thread
is disabled while it is running, once it finishes the button is enabled to
use it again.

I have something like this: (pseudocode)

----------------------------------------------------------------
class MyThread;

class MyObject : QMainWindows {
   Q_OBJECT
   ...
   QPushButton myButton;
   MyThread *myThread; //
   public:
   MyObject();
   public slots:
   void startMyThread (void);
}

MyObject::MyObject {
   ...
   myThread = new MyThread();
   ...
   QObject::connect(myButton,SIGNAL(clicked()),this,SLOT(startMyThread));
   ...
}

void MyObject::startMyThread (void) {
    if ( myThread->isRunning() ) {
      QMessageBox::warning (0/*parent*/, tr("Warning"),
                            tr("ALREADY RUNNING!"));
      return;
   } else {
      myThread->start();
   }
}

class MyThread : QThread {
   Q_OBJECT
   ...
   public:
   MyThread();
   ...
}
----------------------------------------------------------------

The crash comes when I click myButton after the thread has run one or a
couple times, there is no a special number or runs... the thread does not
use pointers nor allocates any kind of dynamic data so it could be related
to null or invalid pointers...

Do I have to exit the thread in a special way? currently it just uses
return; to exit...

Thanks for any help

-- 
Miguel Cardenas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091012/54e0ec51/attachment.html 


More information about the Qt-interest-old mailing list