-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
None
-
4.8.x, 5.0.0
-
None
-
Linux
In Qt 4.8 special code was introduced for handling images. This code broke d&d if you'd have a custom QMimeData subclass that also has application/x-qt-image in its formats list.
Something like this:
class KRITAUI_EXPORT KisMimeData : public QMimeData { Q_OBJECT public: KisMimeData(KisNodeSP node); /// return the node set on this mimedata object -- for internal use KisNodeSP node() const; QStringList formats () const; protected: QVariant retrieveData(const QString &mimetype, QVariant::Type preferredType) const; private: KisNodeSP m_node; };
With formats implemented as
QStringList KisMimeData::formats () const { QStringList f = QMimeData::formats(); if (m_node) { f << "application/x-krita-node" << "application/x-qt-image" } return f; }
will break in a
QAbstractItemModel::dropMimeData(onst QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent)
implementation that relies on the documented behaviour that
const KisMimeData mimedata = qobject_cast<const KisMimeData>(data);
KisNodeSP node = mimedata ? mimedata->node() : 0;
will work; now mimedata will be 0; moreover, formats() returns the extra formats, like "application/x-krita-node", but retrieving that data will not work because the
QVariant v = data->data("application/x-krita-node");
qDebug() << v.isNull() << v.isValid();
Will show that despite the subclasses' retrieveData() method being called, the resulting variant is null.
I looked at what gets passed to the model's QAbstractItemModel::dropMimeData method, and in 4.8, it is the subclass, KisMimeData if the application/x-qt-image format is not present, if it is present, it is a QDropData instance.
I think this commit broke it:
commit c319214f919e3345f673391253f92c6bc0e2a285 Author: David Faure <faure@kde.org> Date: Thu May 19 13:47:37 2011 +0200 Fix in-process drag-n-drop of image data, image/* was not available. If we give the exact initial QMimeData to the dropEvent, we only get application/x-qt-image as available mimeType. We need to go through QDropData to call xdndObtainData, which can still do some in-process optimization, but there we can do the "saving QImage to the requested format" conversion. Task-number: QTBUG-4110 Merge-request: 860 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
- relates to
-
QTBUG-31113 CLONE - QMimeData does not provide image/png if the imagedrag is in-process
-
- Open
-