A folderview QGraphicsView related bug

Ignat Semenov ignat.semenov at blue-systems.com
Fri May 18 18:28:47 UTC 2012


Hello fellow plasma devs and users!

Let me apologise for the long break, now I'm back to some intense bug fixing.

Currently I'm investigating this bug in folderview:

Sometimes folder peek popups appear at (0,0) (upper left corner of the screen)
instead of a position depending on the relevant icon. Quickly narrowed the
issue down to IconView::openPopup (iconview.cpp:2672). First, it computes the
popup point relative to the icon view then it tries to find a QGraphicsView to
map the point to. The bug occurs when the second branch of

if (m_popupCausedWidget)

is executed, i.e. when m_popupCausedWidget is false (if we're not dragging, it
is false). In that second branch, all the views in the scene are iterated to
find the view under mouse:

foreach (QGraphicsView *view, scene()->views()) {
            qDebug() << "view"' << view;
            if (view->underMouse()) {
                gv = view;
                break;
            }

Now according to the docs for QGraphicsView::underMouse(), it returns an
invalid value only if we're dragging, which is handled in the first branch. In
practice, sometimes, none of the views returns true, and gv remains 0, which
leads to the point being calculated as (0,0):

const QPoint pos = gv ? gv->mapToGlobal(gv->mapFromScene(scenePos)) : QPoint();

The debug output reads:

view QGraphicsView(0x19b2ae0)
view QGraphicsView(0x2193580)
view QGraphicsView(0x1fd88b0)
view PanelView(0x21c6dc0)
view DesktopView(0x1837010)
gv DesktopView(0x1837010)

These are the views being checked in openPopup(). Sometimes, when the bug
occurs, none of those returns true in underMouse().

Now the questions are:
1)Why do we need to iterate through the views like this? Anything more elegant
in the Plasma library?
2)Any ideas when underMouse() might fail like this when not dragging? Seems to
be completely random.

Basically, we need to change the iteration loop to something more reliable, and
that will fix the bug.

Best regards,
Ignat Semenov


More information about the Plasma-devel mailing list