Permalink
Browse files

Qt/GameTracker: Remove workaround

  • Loading branch information...
spycrab committed Jul 6, 2018
1 parent 28ca6fe commit 64c3d01551117c418347ce8c2dc5f480cbcbec24
Showing with 6 additions and 31 deletions.
  1. +6 −31 Source/Core/DolphinQt2/GameList/GameTracker.cpp
@@ -13,6 +13,8 @@
#include "DiscIO/DirectoryBlob.h"
#include "DolphinQt2/QtUtils/QueueOnObject.h"
#include "DolphinQt2/QtUtils/RunOnObject.h"
#include "DolphinQt2/Settings.h"
// NOTE: Qt likes to be case-sensitive here even though it shouldn't be thus this ugly regex hack
@@ -119,37 +121,10 @@ 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() && !IsOnRemovableMedia(dir))
return addPath(dir);
if (Settings::Instance().IsAutoRefreshEnabled())
RunOnObject(this, [this, dir] { return addPath(dir); });
m_tracked_paths.push_back(dir);
@@ -158,8 +133,8 @@ bool GameTracker::AddPath(const QString& dir)
bool GameTracker::RemovePath(const QString& dir)
{
if (Settings::Instance().IsAutoRefreshEnabled() && !IsOnRemovableMedia(dir))
return removePath(dir);
if (Settings::Instance().IsAutoRefreshEnabled())
RunOnObject(this, [this, dir] { return removePath(dir); });
const auto index = m_tracked_paths.indexOf(dir);

0 comments on commit 64c3d01

Please sign in to comment.