Regression in Qt 5.9 breaks zanshin drag-n-drop

David Faure faure at kde.org
Sat May 27 13:26:19 UTC 2017


Hi Giuseppe,

after upgrading to Qt 5.9 I found that in zanshin I could no longer drag a 
task and drop it onto a project. Thanks to the extensive unittests in zanshin 
it was immediately clear where the bug was: supportedDragActions() returns -1.

I strongly suspect the commit below.

commit 6255cb893d
Author: Giuseppe D'Angelo <giuseppe.dangelo at kdab.com>
Date:   Thu Nov 3 16:08:55 2016 +0000

    Remove qtypetraits.h's contents altogether
    
    So that QFlags can use an (un)signed int matching the
    underlying type as identified by the compiler and not by us.
    
    Requires fixing a few warnings about sign conversion due to
    QFlags misusages in qtbase that were either plain wrong, or
    were relying on the enum being backed by an (un)signed int
    when it wasn't.
    
    Keep qtypetraits.h in the source tree in order to prevent
    source breaks if some downstream #includes it (note however
    that it did not contain any public API).
    
    Change-Id: Ib3a92b98db7031e793a088fb2a3b306eff4d7a3c
    Reviewed-by: Thiago Macieira <thiago.macieira at intel.com>

diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/
itemmodels/qabstractitemmodel.cpp
index 7fdf107383..3faa8e1441 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -2044,7 +2044,7 @@ Qt::DropActions 
QAbstractItemModel::supportedDropActions() const
 Qt::DropActions QAbstractItemModel::supportedDragActions() const
 {
     Q_D(const QAbstractItemModel);
-    if (d->supportedDragActions != -1)
+    if (d->supportedDragActions != Qt::IgnoreAction)
         return d->supportedDragActions;
     return supportedDropActions();
 }


Qt::IgnoreAction is 0x0, not -1.

src/corelib/global/qnamespace.h:        IgnoreAction = 0x0

I think this code has to be reverted to compare with -1, which is the default 
value for supportedDragActions
in QAbstractItemModelPrivate::QAbstractItemModelPrivate. Alternatively I 
suppose it could be initialized
to IgnoreAction, but I'm not 100% sure of the ramifications of such a change.

=> https://codereview.qt-project.org/195728

If this doesn't get into 5.9.0 I'll have to look into a workaround for 
zanshin...

+10 points for zanshin being better unittested than Qt itself.

-- 
David Faure | david.faure at kdab.com | Managing Director KDAB France
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts



More information about the Zanshin-devel mailing list