diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-08-02 22:49:38 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-08-02 22:52:32 +0200 |
commit | ee07b912a1768ea0b103544f9eeac41f3cf50cf6 (patch) | |
tree | 15bfa7e4a9c098511c1fc89e2b2c240520b85e2d /src/widgets/dialogs | |
parent | 4bfff6a98b59b32605d881a463ad3edc221a7dc8 (diff) | |
parent | a96656a8fb6a3c1fc7765659efff28f807fd0deb (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/plugins/platforms/xcb/qxcbconnection.h
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
src/plugins/styles/mac/qmacstyle_mac.mm
src/widgets/widgets/qdockarealayout.cpp
src/widgets/widgets/qmainwindow.cpp
src/widgets/widgets/qmainwindowlayout.cpp
src/widgets/widgets/qmainwindowlayout_p.h
tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
tests/auto/other/macnativeevents/BLACKLIST
tests/auto/widgets/widgets/qmenu/BLACKLIST
Change-Id: Ic8e724b80a65e7b1af25511b0e674d209265e567
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 10 | ||||
-rw-r--r-- | src/widgets/dialogs/qfileinfogatherer.cpp | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 8 |
3 files changed, 13 insertions, 7 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index b638adeaec..97afce1734 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -3417,7 +3417,7 @@ void QFileDialogPrivate::_q_deleteCurrent() QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows(); for (int i = list.count() - 1; i >= 0; --i) { - QModelIndex index = list.at(i); + QPersistentModelIndex index = list.at(i); if (index == qFileDialogUi->listView->rootIndex()) continue; @@ -3427,7 +3427,6 @@ void QFileDialogPrivate::_q_deleteCurrent() QString fileName = index.data(QFileSystemModel::FileNameRole).toString(); QString filePath = index.data(QFileSystemModel::FilePathRole).toString(); - bool isDir = model->isDir(index); QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); #if QT_CONFIG(messagebox) @@ -3443,13 +3442,16 @@ void QFileDialogPrivate::_q_deleteCurrent() QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) return; + // the event loop has run, we have to validate if the index is valid because the model might have removed it. + if (!index.isValid()) + return; + #else if (!(p & QFile::WriteUser)) return; #endif // QT_CONFIG(messagebox) - // the event loop has run, we can NOT reuse index because the model might have removed it. - if (isDir) { + if (model->isDir(index) && !model->fileInfo(index).isSymLink()) { if (!removeDirectory(filePath)) { #if QT_CONFIG(messagebox) QMessageBox::warning(q, q->windowTitle(), diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 9f2d15d31b..710ee611b9 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -98,7 +98,7 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent) if (listener.canConvert<QObject *>()) { if (QObject *driveListener = listener.value<QObject *>()) { connect(driveListener, SIGNAL(driveAdded()), this, SLOT(driveAdded())); - connect(driveListener, SIGNAL(driveRemoved(QString)), this, SLOT(driveRemoved())); + connect(driveListener, SIGNAL(driveRemoved()), this, SLOT(driveRemoved())); } } # endif // Q_OS_WIN && !Q_OS_WINRT diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 872b8daf22..f88ac71cf3 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -203,8 +203,12 @@ QFileInfo QFileSystemModel::fileInfo(const QModelIndex &index) const bool QFileSystemModel::remove(const QModelIndex &aindex) { - const QString path = filePath(aindex); - const bool success = QFileInfo(path).isFile() ? QFile::remove(path) : QDir(path).removeRecursively(); + Q_D(QFileSystemModel); + + const QString path = d->filePath(aindex); + const QFileInfo fileInfo(path); + const bool success = (fileInfo.isFile() || fileInfo.isSymLink()) + ? QFile::remove(path) : QDir(path).removeRecursively(); #ifndef QT_NO_FILESYSTEMWATCHER if (success) { QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func()); |