[Digikam-devel] Fwd: extragear/graphics/digikam/libs/widgets/common

Andi Clemens andi.clemens at gmx.net
Fri Oct 2 14:46:25 BST 2009


Unfortuantely I had no backtrace, I was using a release build for performance 
tests. Well anyway using QPointer AND checking for valid pointer in 
moveToParent() should avoid any possible crash now.

Andi

On Friday 02 October 2009 15:39:46 Gilles Caulier wrote:
> With GDB, the backtrace must said parent=0x0. It's clear... else
> pointer is a dumy valid.
> 
> Yes QPointer must reset parent addess to zero when parent widget is
>  deleted...
> 
> Gilles
> 
> 2009/10/2 Andi Clemens <andi.clemens at gmx.net>:
> > Since we don't delete the pointer in the DCursorTracker, the error must
> > have been an invalid access due to a nullpointer.
> > But QPointer should help us here, too.
> > If not, we might need to check in every method of DCursorTracker if the
> > parent pointer is still valid.
> > Right?
> >
> > Andi
> >
> >
> > ---------- Message transféré ----------
> > From: Andi Clemens <andi.clemens at gmx.net>
> > To: kde-commits at kde.org
> > Date: Fri, 02 Oct 2009 13:28:30 +0000
> > Subject: extragear/graphics/digikam/libs/widgets/common
> > SVN commit 1030535 by aclemens:
> >
> > I experienced a crash in DCursorTracker, I guess due to the fact that the
> > parent widget was deleted before the DCursorTracker was destroyed.
> > I was not able to reproduce it anymore, but as the Qt docs describe, it
> > is always better to use a QPointer when saving pointers of other widgets
> > inside a class. These pointers will keep track of all references and
> > destroy themselves (set themselves to NULL) when all references are gone.
> > This should avoid the crash I experienced in here.
> >
> >  M  +6 -5      dcursortracker.cpp
> >
> >
> > ---
> > trunk/extragear/graphics/digikam/libs/widgets/common/dcursortracker.cpp
> > #1030534:1030535 @@ -32,6 +32,7 @@
> >  #include <QFrame>
> >  #include <QLabel>
> >  #include <QMouseEvent>
> > +#include <QPointer>
> >  #include <QTimer>
> >  #include <QToolTip>
> >
> > @@ -55,11 +56,11 @@
> >         parent        = 0;
> >     }
> >
> > -    Qt::Alignment alignment;
> > -    bool          enable;
> > -    bool          keepOpen;
> > -    QTimer*       autoHideTimer;
> > -    QWidget*      parent;
> > +    Qt::Alignment     alignment;
> > +    bool              enable;
> > +    bool              keepOpen;
> > +    QTimer*           autoHideTimer;
> > +    QPointer<QWidget> parent;
> >  };
> >
> >  DCursorTracker::DCursorTracker(const QString& txt, QWidget *parent,
> > Qt::Alignment align)
> >
> > _______________________________________________
> > Digikam-devel mailing list
> > Digikam-devel at kde.org
> > https://mail.kde.org/mailman/listinfo/digikam-devel
> 
> _______________________________________________
> Digikam-devel mailing list
> Digikam-devel at kde.org
> https://mail.kde.org/mailman/listinfo/digikam-devel
> 



More information about the Digikam-devel mailing list