[Development] Help debugging "impossible condition"

Giuseppe D'Angelo dangelog at gmail.com
Sun May 6 00:18:18 CEST 2012


On 5 May 2012 21:18, Thiago Macieira <thiago.macieira at intel.com> wrote:
> One of my tasks was to clean up QEvent. I have done mostly so, but I wanted to
> go one step further and put a warning to anyone (ab)using the QEvent d-
> pointer. That's change
>        https://codereview.qt-project.org/#change,24994
>
> Unfortunately, I've hit a snag and I need help. Somehow, something is setting
> the d pointer in one or both QEvents created on the stack in
> QApplicationPrivate::dispatchEnterLeave, causing my change to crash in
> tst_graphicsview:hoverLeave.
>
> I can't reproduce it. On my system, the crash doesn't happen. In fact, the
> function in question isn't called at all. And the test fails -- which might be
> related.
>
> So I need help. Can anyone:
> a) help me make the test pass and, in the process, crash for me?
> or
> b) debug the issue? I suggest putting a breakpoint in
> QApplicationPrivate::dispatchEnterLeave, then a watchpoint in those QEvent's
> d-pointers and see where they get changed. A full fix would be nice, but I'll
> settle for the location of where the d pointer is set.

I think I figured it out in a much simpler way:

peppe at queen:~/projects/src/qt5/qtbase/src/widgets/graphicsview
(qeventdpointer)$ egrep -C2 -n "event->d\\b" *
qgraphicsscene.cpp-3479-    case QEvent::Leave:
qgraphicsscene.cpp-3480-        // hackieshly unpacking the viewport
pointer from the leave event.
qgraphicsscene.cpp:3481:        d->leaveScene(reinterpret_cast<QWidget
*>(event->d));
qgraphicsscene.cpp-3482-        break;
qgraphicsscene.cpp-3483-    case QEvent::GraphicsSceneHelp:
--
qgraphicsview.cpp-2790-        d->useLastMouseEvent = false;
qgraphicsview.cpp-2791-        // a hack to pass a viewport pointer to
the scene inside the leave event
qgraphicsview.cpp:2792:        Q_ASSERT(event->d == 0);
qgraphicsview.cpp:2793:        event->d =
reinterpret_cast<QEventPrivate *>(viewport());
qgraphicsview.cpp-2794-        QApplication::sendEvent(d->scene, event);
qgraphicsview.cpp-2795-        break;

Does it ring any bell to you?

-- 
Giuseppe D'Angelo



More information about the Development mailing list