I found the problem.
I had a typical
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
{
Q_OBJECT
public:
~MyThread();
void run();
};
#endif // MYTHREAD_H
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
class MyThread : public QThread
{
Q_OBJECT
public:
MyThread(QObject *parent = 0);
~MyThread();
void run();
};
#endif // MYTHREAD_H
To copy to clipboard, switch view to plain text mode
setup and, as advised in the Qt documentation, I simply re-implemented the run() function. In my main thread, I had
MyThread *thread = new MyThread();
thread->start();
MyThread *thread = new MyThread();
thread->start();
To copy to clipboard, switch view to plain text mode
and this is where things went wrong, as I'd understood from the Qt docs that start() would automatically call run()
void QThread::start ( Priority priority = InheritPriority ) [slot]
Begins execution of the thread by calling run(), which should be reimplemented in a QThread subclass to contain your code. The operating system will schedule the thread according to the priority parameter. If the thread is already running, this function does nothing.
The effect of the priority parameter is dependent on the operating system's scheduling policy. In particular, the priority will be ignored on systems that do not support thread priorities (such as on Linux, see
http://linux.die.net/man/2/sched_setscheduler for more details).
See also run() and terminate().
I can't remember why I didn't just call run() from the beginning (I'm not sure if there even was a valid reason), but the problem went away as soon as I changed my thread execution call to
MyThread *thread = new MyThread();
thread->run();
MyThread *thread = new MyThread();
thread->run();
To copy to clipboard, switch view to plain text mode
I'm not sure why this worked (or, for that matter, why calling start() didn't), but I now have a complete profile in Dependency Walker and no more crashes.
Fingers crossed that the deployment will go more smoothly than this did!
Bookmarks