Weird crash with QProgressDialog: Qt bug?
Simon Hausmann
hausmann at kde.org
Fri Aug 9 13:27:50 BST 2002
On Fri, Aug 09, 2002 at 01:48:20PM +0200, Michael Goffioul wrote:
> I encountered a weird crash when dealing with a QProgressDialog in
> KDEPrint, and I think it might be due to a Qt bug. Before reporting it
> to TT, I'd like to have an external opinion.
>
> The situation is the following. I have a widget w1, included in
> a QWidgetStack, in turn included in a QDialog d1. Now I create a
> QProgressDialog with w1 as "parent/creator". In QProgressDialog's
> code, you can see that the QDialog ctor is called with
> creator->topLevelWidget() as parent, that means that my progress
> dialog has w1 as creator, and d1 as parent.
>
> Now, when you delete d1, all children are deleted recursively,
> including w1 and the progress dialog. But if w1 is deleted before
> the progress dialog, you get a crash because ~QProgressDialog tries
> to access its creator (w1 in this case). And this is the crash I got.
>
> My workaround was to create the progress dialog with w1->topLevelWidget()
> as creator as well, such that the real parent and the creator of the
> progress dialog are the same.
>
> Does this sound logical, or am I completely wrong? Is it possible
> that a creator of a progress dialog gets deleted before the dialog
> itself?
Sounds pretty logical. I don't understand why QPD passes
topLevelWidget() instead of creator though. That sounds like the
real bug to me, as it violates the rule that the parent object a
derived class passes to the base class is passed as parent object to
the QObject ctor. The current behaviour looks inconsistent to that.
Simon
More information about the kde-core-devel
mailing list