summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2018-07-05 21:56:09 +0200
committerspycrab <spycrab@users.noreply.github.com>2018-07-05 22:07:41 +0200
commitbb2eed2df32c6ab4798ca9d99a88d446fe4bc4df (patch)
tree6fbccd60a12febba699f10ccdd114a9a3d7d92d6 /Source
parent9ea3e833bafff0d67e38b0f7f2dd42878d9af15d (diff)
Qt/GameTracker: Work around Qt crash
Works around a bug in QtCore that will cause crashes when QFileSystemWatcher::addPath is called on a directory that is located on a removable device (USB mass storage devices, etc.)
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt2/GameList/GameTracker.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt2/GameList/GameTracker.cpp b/Source/Core/DolphinQt2/GameList/GameTracker.cpp
index 71f4db70d6..19e468aa30 100644
--- a/Source/Core/DolphinQt2/GameList/GameTracker.cpp
+++ b/Source/Core/DolphinQt2/GameList/GameTracker.cpp
@@ -119,9 +119,36 @@ void GameTracker::StartInternal()
m_cache.Save();
}
+// Works around a bug in QtCore that will cause crashes when QFileSystemWatcher::addPath
+// is called on a directory that is located on a removable device
+static bool IsOnRemovableMedia(const QString& dir)
+{
+#ifdef _WIN32
+ const QString absolute_dir = QFileInfo(dir).absolutePath();
+ if (absolute_dir.startsWith(QStringLiteral("//")))
+ return true;
+ const QString root_dir = QDir::toNativeSeparators(absolute_dir.left(3));
+ auto type = GetDriveType(root_dir.toStdWString().c_str());
+
+ switch (type)
+ {
+ case DRIVE_REMOVABLE:
+ case DRIVE_REMOTE:
+ case DRIVE_CDROM:
+ case DRIVE_UNKNOWN:
+ case DRIVE_NO_ROOT_DIR:
+ return true;
+ default:
+ return false;
+ }
+#else
+ return false;
+#endif
+}
+
bool GameTracker::AddPath(const QString& dir)
{
- if (Settings::Instance().IsAutoRefreshEnabled())
+ if (Settings::Instance().IsAutoRefreshEnabled() && !IsOnRemovableMedia(dir))
return addPath(dir);
m_tracked_paths.push_back(dir);
@@ -131,7 +158,7 @@ bool GameTracker::AddPath(const QString& dir)
bool GameTracker::RemovePath(const QString& dir)
{
- if (Settings::Instance().IsAutoRefreshEnabled())
+ if (Settings::Instance().IsAutoRefreshEnabled() && !IsOnRemovableMedia(dir))
return removePath(dir);
const auto index = m_tracked_paths.indexOf(dir);