Remove the crash pending warning

Even though the intentions of this warning were good, the warning
was a bit harsh. In addition, in certain circumstances
(like the autotest demonstrates) we could end up calling object()
on an interface where the object was in the destructor. This
could happen because: *after* we got the destroyed() signal, the
widget would still notify the accessibility framework of a FocusOut
event.
Since the code even called object() from isValid(), we could not even
(as a defensive measure to circumvent this issue) check the isValid()
of an interface without getting this warning (duh).
So - for isValid(), the warning is not needed at
all, since the caller will of course check the result of isValid() and
act accordingly.

As for the result of object(), it should always be a pointer, but it
might point to a partially destroyed object. To detect this, you simply
check isValid() first:

if (iface->isValid())
    doStuff(iface->object());

Change-Id: I206307fe618806133d8c6bc338c412d0009d7181
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
bb10
Jan Arve Saether 2013-05-03 16:36:05 +02:00 committed by The Qt Project
parent cd5d1524a0
commit 9504516847
1 changed files with 0 additions and 4 deletions

View File

@ -100,10 +100,6 @@ QAccessibleObject::~QAccessibleObject()
*/
QObject *QAccessibleObject::object() const
{
#ifndef QT_NO_DEBUG
if (!d->object)
qWarning("QAccessibleInterface is invalid. Crash pending...");
#endif
return d->object;
}