mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Add initial paths to GameTracker after construction
It's strange to see GameTracker add its own initial paths in construction, because you might expect a race condition where the GameLoaded signal is emitted before it gets connected to in GameListModel. In fact, this doesn't happen, but only because of how it abuses the Qt signals mechanism to load files asynchronously: GameLoader emits a GameLoaded signal which gets forwarded to the GameTracker::GameLoaded signal _after_ control returns to the event loop, at which point GameListModel has connected. This commit moves the logic of adding initial paths out of GameTracker to a point after the signals are connected, which is more obvious and doesn't rely on how GameTracker implements concurrency.
This commit is contained in:
parent
8d7f28e79b
commit
7d9ad88bc5
@ -17,6 +17,9 @@ GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
||||
connect(this, &GameListModel::DirectoryAdded, &m_tracker, &GameTracker::AddDirectory);
|
||||
connect(this, &GameListModel::DirectoryRemoved, &m_tracker, &GameTracker::RemoveDirectory);
|
||||
|
||||
for (const QString& dir : Settings::Instance().GetPaths())
|
||||
m_tracker.AddDirectory(dir);
|
||||
|
||||
connect(&Settings::Instance(), &Settings::ThemeChanged, [this] {
|
||||
// Tell the view to repaint. The signal 'dataChanged' also seems like it would work here, but
|
||||
// unfortunately it won't cause a repaint until the view is focused.
|
||||
|
@ -28,9 +28,6 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
|
||||
connect(m_loader, &GameLoader::GameLoaded, this, &GameTracker::GameLoaded);
|
||||
|
||||
m_loader_thread.start();
|
||||
|
||||
for (QString dir : Settings::Instance().GetPaths())
|
||||
AddDirectory(dir);
|
||||
}
|
||||
|
||||
GameTracker::~GameTracker()
|
||||
|
Loading…
Reference in New Issue
Block a user