[vtkusers] vtkAviWriter and QThread problem

Barth, Sebastian sebastian.barth at iosb.fraunhofer.de
Thu Jul 1 05:20:57 EDT 2010


Here is the simplified source code I use:

In the main thread:

{
	//...

	QThread videoThread = new QThread();
	VideoWriter writer = new VideoWriter();
	QTimer * timer = new QTimer();

	writer->moveToThread(videoThread);

	connect(timer, SIGNAL(timeout()), writer, SLOT(startWriter()));

	videoThread->start();
	timer.start(0);

	//...
}

If you are confused about the way I use QThreads, then take a look at:
http://labs.qt.nokia.com/blogs/2010/06/17/youre-doing-it-wrong/
http://labs.trolltech.com/blogs/2006/12/04/threading-without-the-headache/


The slot in the writer class:

void VideoWriter::startWriter()
{
	qDebug() << "begin selectOptions on Thread:" << this->thread()->currentThreadId() << QThread::currentThreadId();

	this->aviWriter->SetPromptCompressionOptions(true);
	this->aviWriter->Start();
    
	qDebug() << "end writeImageData" << this->thread()->currentThreadId() << QThread::currentThreadId();
}


-----Ursprüngliche Nachricht-----
Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im Auftrag von Barth, Sebastian
Gesendet: Donnerstag, 1. Juli 2010 10:10
An: vtkusers at vtk.org
Betreff: [vtkusers] vtkAviWriter and QThread problem

Hello vtkusers,


I use Qt 4.6.2 with VTK 5.6.0 to display a cluster of points.

I try to create a video of my simulation with the help of vtkAVIWriter. For that I have a second QThread with an own event loop. Anyway, when I start a slot of a QObject derived class on this thread which calls the vtkAviWriter::Start() method, a Windows dialog prompts for selecting the compress options and the slot waits for the dialog to close to continue its work. 

The curious problem is, that the started slot waits correctly, while the event loop of the QThread continues and begins to execute the next signal/slot in its event queue. 

When the slot that started the windows dialog can continue its work because the dialog has returned, the event loop stops its current work again and continues the execution of the waiting slot. When this slot returns the last interrupted slot on the event queue continues. 

If I set SetPromptCompressionOptions(false), the window does not appear and everything works fine and in a row (serialized)!

Do you have any ideas?

Thanks a lot.

Sebastian Barth


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list