qt-interest@trolltech.com
[Top] [All Lists]

Threading QPrinter to avoid blocking (in Unix)

Subject: Threading QPrinter to avoid blocking in Unix
From: Kaleb Pederson
Date: Sat, 06 Nov 2004 14:00:02 -0800
I have an application that prints some complex reports.  The reports print
fine, but my application is blocked while the printing happens.

1) I wanted to confirm that printing to a QPrinter is thread safe.  I've
read through all the thread documentation, and it never seems to refer to
anything that would cause problems as QPrinter is not QObject based, nor
does it do much else in the gui realm.

2) Although I have threaded printing in my application, it doesn't help (I
haven't seen any negative affects though either).  I took a look through
the qt source and found the following:

When the QPainter.begin() a couple threads are forked one of which exec's
'true' after forking.  This is done so that, ideally, a call to waitpid()
which is made later (QPainter.end()) doesn't ever have to wait (see
qprinter_unix.cpp +465, in qt-3.3.3).

The behavior seems like the whole process is waiting in that the application
blocks.  However, I attached gdb to it and there aren't any other threads,
so it doesn't look like a thread is hanging out.  The backtraces don't
reveal much, and I didn't see any calls to QApplication.lock().

Before I start modifying code and recompiling so I can see what's really
going on, I thought I'd look for help.

Any suggestions?  Any way to make QPrinter not block the application? Any
good ways to identify where all the time is being spent (I'll have to
recompile with debug support before I can profile and stuff).

Thanks for the help.

--Kaleb

--
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>
  • Threading QPrinter to avoid blocking (in Unix), Kaleb Pederson <=