[Qt-interest] Immortal Programs!

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Mon Jul 6 17:41:08 CEST 2009


Gary Coulbourne wrote on Monday, July 06, 2009 5:28 PM:

> > ...
> The application has already finished getting all of the data over the
>  network. I added a bunch of additional debugging, and what appears
> to happen is that the data comes in over the network and gets passed
> to QXmlSimpleReader.  QXSR takes a long time to process the data, it
> doesn't seem to matter if it is done incrementally or as a whole
> chunk.    
> 
> What is confusing me is why the application doesn't quit when the
> last window is closed, unless QXSR has finished processing the data. 
> Wouldn't quitting also kill that processing? 

What is confusing me is that how could the QXmlSimpleReader be busy, and NOT blocking the GUI, if it is in the same thread as the GUI (as you have just confirmed yourself)? Or put into other words: how can you close the Window if your GUI is blocked?

Usually (on Windows) you get an "Application does not respond" (and you can hence *force* the application to quit) if it is still busy processing data in the *same* thread as the GUI thread (aka main thread).

Now the Qt network module is AFAICR indeed *not* multithreaded, but event-driven. That is your application gets notified by Qt signals, whenever there has data arrived and is ready to be processed.

Now if it is really as you say, and you don't use a "worker thread", that would mean that the processing (done by the QXmlSimpleReader) is done in the GUI (main) thread and would hence block the GUI and you would not be able to close the application Window (since the Qt event queue would not be processed until your slot - where you deal with the XML data - returns).

So how exactly do you close "the last window"? Is it really closed properly? Or are you somehow sending a SIG-INT (interrupt signal) and waiting for the application to really terminate? What OS was that again you are using? Maybe your Window Manager does seem to close the Window, when in fact it is not (it is maybe merely removed from the desktop by the Window Manager, but the Qt app is not yet able to process that "Window Close" event, because it is still busy processing the XML)?


Cheers, Oliver 
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list