[Interest] crashing Qt through a QObject's dtor
faure at kde.org
Tue Jan 6 13:07:02 CET 2015
On Tuesday 06 January 2015 12:35:01 René J.V. Bertin wrote:
> On Tuesday January 06 2015 11:36:18 René J.V. Bertin wrote:
> > And then the hackers' delight question:
> > Staring at the code at almost 3am this morning it occurred to me that
> > there is nothing wrong per se if QAction::isEnabled() returns false if
> > the d pointer is NULL (an invalid QAction cannot/shouldn't be enabled),
> > so I changed `return d->enabled` to `return d? d->enabled : false;` .
> > Haven't seen the crash occur since ...
> The question here is of course: how wrong is that approach?
It's wrong because it's fixing the symptom (null d pointer) instead of fixing
the cause (using an action that was already deleted).
My recommendation: run the app in valgrind.
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
More information about the Interest