mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
BookmarksModel: Use internalPointer when passing mimedata
internalPointer() is the same as internalId(), which means that it actually is not safe to use them. But for now, this at least fixes crashes on FreeBSD and works quite well in most cases. Closes #1565
This commit is contained in:
parent
dc5dafbe9a
commit
42ebb227c6
@ -192,12 +192,6 @@ QStringList BookmarksModel::mimeTypes() const
|
||||
return types;
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
#define QMODELINDEX_INTERNALID_TYPE quint32
|
||||
#else
|
||||
#define QMODELINDEX_INTERNALID_TYPE quintptr
|
||||
#endif
|
||||
|
||||
QMimeData* BookmarksModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
@ -208,7 +202,7 @@ QMimeData* BookmarksModel::mimeData(const QModelIndexList &indexes) const
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
// If item's parent (=folder) is also selected, we will just move the whole folder
|
||||
if (index.isValid() && index.column() == 0 && !indexes.contains(index.parent())) {
|
||||
stream << index.row() << (QMODELINDEX_INTERNALID_TYPE) index.internalId();
|
||||
stream << index.row() << (quintptr) index.internalPointer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,11 +231,11 @@ bool BookmarksModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
int row;
|
||||
QMODELINDEX_INTERNALID_TYPE id;
|
||||
quintptr ptr;
|
||||
|
||||
stream >> row >> id;
|
||||
stream >> row >> ptr;
|
||||
|
||||
QModelIndex index = createIndex(row, 0, id);
|
||||
QModelIndex index = createIndex(row, 0, (void*) ptr);
|
||||
BookmarkItem* itm = item(index);
|
||||
|
||||
Q_ASSERT(index.isValid());
|
||||
|
Loading…
Reference in New Issue
Block a user