Windows/QFileSystemModel: Fix updating of removed drives
Previously, the updating of drives in QFileSystemModel was connected
to a signal triggering when a drive containing watched files was
removed via QFileSystemWatcher notification. This did not trigger
when a drive that was not expanded in the view was removed, since
no files were watched.
Since QFileSystemModel is not interested in the path of the drive
being removed, add a generic signal triggered by
DBT_DEVTYP_VOLUME/DBT_DEVICEREMOVECOMPLETE and use that to update
the drives.
Complements 8e79806d08
.
Task-number: QTBUG-18729
Task-number: QTBUG-53436
Change-Id: Ibcde4665824c41151042237d4d620c48bc1e2e18
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
6b7b37cf2e
commit
256854cf97
@ -113,7 +113,8 @@ public:
|
||||
|
||||
signals:
|
||||
void driveAdded();
|
||||
void driveRemoved(const QString &);
|
||||
void driveRemoved(); // Some drive removed
|
||||
void driveRemoved(const QString &); // Watched/known drive removed
|
||||
void driveLockForRemoval(const QString &);
|
||||
void driveLockForRemovalFailed(const QString &);
|
||||
|
||||
@ -252,7 +253,8 @@ inline void QWindowsRemovableDriveListener::handleDbtDriveArrivalRemoval(const M
|
||||
case DBT_DEVICEARRIVAL:
|
||||
emit driveAdded();
|
||||
break;
|
||||
case DBT_DEVICEREMOVECOMPLETE: // handled by DBT_DEVTYP_HANDLE above
|
||||
case DBT_DEVICEREMOVECOMPLETE: // See above for handling of drives registered with watchers
|
||||
emit driveRemoved();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -348,7 +350,8 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent
|
||||
this, &QWindowsFileSystemWatcherEngine::driveLockForRemoval);
|
||||
QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveLockForRemovalFailed,
|
||||
this, &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed);
|
||||
QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveRemoved,
|
||||
QObject::connect(m_driveListener,
|
||||
QOverload<const QString &>::of(&QWindowsRemovableDriveListener::driveRemoved),
|
||||
this, &QWindowsFileSystemWatcherEngine::driveRemoved);
|
||||
#endif // !Q_OS_WINRT
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user