mirror of https://github.com/PCSX2/pcsx2.git
Host/VMManager: Remove save state cache invalidation and just populate lists every time
Fixes issues where inexistant save states are listed in dropdowns
This commit is contained in:
parent
d2bdb85dc8
commit
f73b497b67
|
@ -351,10 +351,6 @@ void Host::OnSaveStateSaved(const std::string_view& filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::InvalidateSaveStateCache()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Host::RunOnCPUThread(std::function<void()> function, bool block /* = false */)
|
void Host::RunOnCPUThread(std::function<void()> function, bool block /* = false */)
|
||||||
{
|
{
|
||||||
pxFailRel("Not implemented");
|
pxFailRel("Not implemented");
|
||||||
|
|
|
@ -157,7 +157,7 @@ void MainWindow::initialize()
|
||||||
restoreStateFromConfig();
|
restoreStateFromConfig();
|
||||||
switchToGameListView();
|
switchToGameListView();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateSaveStateMenus(QString(), QString(), 0);
|
updateSaveStateMenusEnableState(false);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
registerForDeviceNotifications();
|
registerForDeviceNotifications();
|
||||||
|
@ -1259,11 +1259,6 @@ void MainWindow::cancelGameListRefresh()
|
||||||
m_game_list_widget->cancelRefresh();
|
m_game_list_widget->cancelRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::invalidateSaveStateCache()
|
|
||||||
{
|
|
||||||
m_save_states_invalidated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::reportError(const QString& title, const QString& message)
|
void MainWindow::reportError(const QString& title, const QString& message)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, title, message);
|
QMessageBox::critical(this, title, message);
|
||||||
|
@ -1374,11 +1369,6 @@ std::optional<WindowInfo> MainWindow::getWindowInfo()
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::InvalidateSaveStateCache()
|
|
||||||
{
|
|
||||||
QMetaObject::invokeMethod(g_main_window, &MainWindow::invalidateSaveStateCache, Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onGameListRefreshProgress(const QString& status, int current, int total)
|
void MainWindow::onGameListRefreshProgress(const QString& status, int current, int total)
|
||||||
{
|
{
|
||||||
m_ui.statusBar->showMessage(status);
|
m_ui.statusBar->showMessage(status);
|
||||||
|
@ -1581,14 +1571,14 @@ void MainWindow::onChangeDiscMenuAboutToHide()
|
||||||
|
|
||||||
void MainWindow::onLoadStateMenuAboutToShow()
|
void MainWindow::onLoadStateMenuAboutToShow()
|
||||||
{
|
{
|
||||||
if (m_save_states_invalidated)
|
updateSaveStateMenusEnableState(!m_current_game_serial.isEmpty());
|
||||||
updateSaveStateMenus(m_current_disc_path, m_current_game_serial, m_current_game_crc);
|
populateLoadStateMenu(m_ui.menuLoadState, m_current_disc_path, m_current_game_serial, m_current_game_crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onSaveStateMenuAboutToShow()
|
void MainWindow::onSaveStateMenuAboutToShow()
|
||||||
{
|
{
|
||||||
if (m_save_states_invalidated)
|
updateSaveStateMenusEnableState(!m_current_game_serial.isEmpty());
|
||||||
updateSaveStateMenus(m_current_disc_path, m_current_game_serial, m_current_game_crc);
|
populateSaveStateMenu(m_ui.menuSaveState, m_current_game_serial, m_current_game_crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onViewToolbarActionToggled(bool checked)
|
void MainWindow::onViewToolbarActionToggled(bool checked)
|
||||||
|
@ -1889,7 +1879,7 @@ void MainWindow::onVMStarting()
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
|
|
||||||
// prevent loading state until we're fully initialized
|
// prevent loading state until we're fully initialized
|
||||||
updateSaveStateMenus(QString(), QString(), 0);
|
updateSaveStateMenusEnableState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onVMStarted()
|
void MainWindow::onVMStarted()
|
||||||
|
@ -1969,7 +1959,7 @@ void MainWindow::onGameChanged(const QString& path, const QString& elf_override,
|
||||||
m_current_game_name = name;
|
m_current_game_name = name;
|
||||||
m_current_game_crc = crc;
|
m_current_game_crc = crc;
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateSaveStateMenus(path, serial, crc);
|
updateSaveStateMenusEnableState(!serial.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showEvent(QShowEvent* event)
|
void MainWindow::showEvent(QShowEvent* event)
|
||||||
|
@ -2722,6 +2712,8 @@ static QString formatTimestampForSaveStateMenu(time_t timestamp)
|
||||||
|
|
||||||
void MainWindow::populateLoadStateMenu(QMenu* menu, const QString& filename, const QString& serial, quint32 crc)
|
void MainWindow::populateLoadStateMenu(QMenu* menu, const QString& filename, const QString& serial, quint32 crc)
|
||||||
{
|
{
|
||||||
|
menu->clear();
|
||||||
|
|
||||||
if (serial.isEmpty())
|
if (serial.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2796,6 +2788,8 @@ void MainWindow::populateLoadStateMenu(QMenu* menu, const QString& filename, con
|
||||||
|
|
||||||
void MainWindow::populateSaveStateMenu(QMenu* menu, const QString& serial, quint32 crc)
|
void MainWindow::populateSaveStateMenu(QMenu* menu, const QString& serial, quint32 crc)
|
||||||
{
|
{
|
||||||
|
menu->clear();
|
||||||
|
|
||||||
if (serial.isEmpty())
|
if (serial.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2825,21 +2819,14 @@ void MainWindow::populateSaveStateMenu(QMenu* menu, const QString& serial, quint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateSaveStateMenus(const QString& filename, const QString& serial, quint32 crc)
|
void MainWindow::updateSaveStateMenusEnableState(bool enable)
|
||||||
{
|
{
|
||||||
const bool load_enabled = !serial.isEmpty();
|
const bool load_enabled = enable;
|
||||||
const bool save_enabled = !serial.isEmpty() && s_vm_valid;
|
const bool save_enabled = enable && s_vm_valid;
|
||||||
m_ui.menuLoadState->clear();
|
|
||||||
m_ui.menuLoadState->setEnabled(load_enabled);
|
m_ui.menuLoadState->setEnabled(load_enabled);
|
||||||
m_ui.actionLoadState->setEnabled(load_enabled);
|
m_ui.actionLoadState->setEnabled(load_enabled);
|
||||||
m_ui.menuSaveState->clear();
|
|
||||||
m_ui.menuSaveState->setEnabled(save_enabled);
|
m_ui.menuSaveState->setEnabled(save_enabled);
|
||||||
m_ui.actionSaveState->setEnabled(save_enabled);
|
m_ui.actionSaveState->setEnabled(save_enabled);
|
||||||
m_save_states_invalidated = false;
|
|
||||||
if (load_enabled)
|
|
||||||
populateLoadStateMenu(m_ui.menuLoadState, filename, serial, crc);
|
|
||||||
if (save_enabled)
|
|
||||||
populateSaveStateMenu(m_ui.menuSaveState, serial, crc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::doStartFile(std::optional<CDVD_SourceType> source, const QString& path)
|
void MainWindow::doStartFile(std::optional<CDVD_SourceType> source, const QString& path)
|
||||||
|
|
|
@ -114,7 +114,6 @@ public Q_SLOTS:
|
||||||
void checkForUpdates(bool display_message, bool force_check);
|
void checkForUpdates(bool display_message, bool force_check);
|
||||||
void refreshGameList(bool invalidate_cache);
|
void refreshGameList(bool invalidate_cache);
|
||||||
void cancelGameListRefresh();
|
void cancelGameListRefresh();
|
||||||
void invalidateSaveStateCache();
|
|
||||||
void reportError(const QString& title, const QString& message);
|
void reportError(const QString& title, const QString& message);
|
||||||
bool confirmMessage(const QString& title, const QString& message);
|
bool confirmMessage(const QString& title, const QString& message);
|
||||||
void runOnUIThread(const std::function<void()>& func);
|
void runOnUIThread(const std::function<void()>& func);
|
||||||
|
@ -260,7 +259,7 @@ private:
|
||||||
void loadSaveStateFile(const QString& filename, const QString& state_filename);
|
void loadSaveStateFile(const QString& filename, const QString& state_filename);
|
||||||
void populateLoadStateMenu(QMenu* menu, const QString& filename, const QString& serial, quint32 crc);
|
void populateLoadStateMenu(QMenu* menu, const QString& filename, const QString& serial, quint32 crc);
|
||||||
void populateSaveStateMenu(QMenu* menu, const QString& serial, quint32 crc);
|
void populateSaveStateMenu(QMenu* menu, const QString& serial, quint32 crc);
|
||||||
void updateSaveStateMenus(const QString& filename, const QString& serial, quint32 crc);
|
void updateSaveStateMenusEnableState(bool enable);
|
||||||
void doStartFile(std::optional<CDVD_SourceType> source, const QString& path);
|
void doStartFile(std::optional<CDVD_SourceType> source, const QString& path);
|
||||||
void doDiscChange(CDVD_SourceType source, const QString& path);
|
void doDiscChange(CDVD_SourceType source, const QString& path);
|
||||||
|
|
||||||
|
@ -292,7 +291,6 @@ private:
|
||||||
|
|
||||||
bool m_display_created = false;
|
bool m_display_created = false;
|
||||||
bool m_relative_mouse_mode = false;
|
bool m_relative_mouse_mode = false;
|
||||||
bool m_save_states_invalidated = false;
|
|
||||||
bool m_was_paused_on_surface_loss = false;
|
bool m_was_paused_on_surface_loss = false;
|
||||||
bool m_was_disc_change_request = false;
|
bool m_was_disc_change_request = false;
|
||||||
bool m_is_closing = false;
|
bool m_is_closing = false;
|
||||||
|
|
|
@ -1339,8 +1339,6 @@ void VMManager::ZipSaveState(std::unique_ptr<ArchiveEntryList> elist,
|
||||||
}
|
}
|
||||||
|
|
||||||
DevCon.WriteLn("Zipping save state to '%s' took %.2f ms", filename, timer.GetTimeMilliseconds());
|
DevCon.WriteLn("Zipping save state to '%s' took %.2f ms", filename, timer.GetTimeMilliseconds());
|
||||||
|
|
||||||
Host::InvalidateSaveStateCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMManager::ZipSaveStateOnThread(std::unique_ptr<ArchiveEntryList> elist, std::unique_ptr<SaveStateScreenshotData> screenshot,
|
void VMManager::ZipSaveStateOnThread(std::unique_ptr<ArchiveEntryList> elist, std::unique_ptr<SaveStateScreenshotData> screenshot,
|
||||||
|
|
|
@ -258,7 +258,4 @@ namespace Host
|
||||||
|
|
||||||
/// Provided by the host; called once per frame at guest vsync.
|
/// Provided by the host; called once per frame at guest vsync.
|
||||||
void CPUThreadVSync();
|
void CPUThreadVSync();
|
||||||
|
|
||||||
/// Provided by the host; called when a state is saved, and the frontend should invalidate its save state cache.
|
|
||||||
void InvalidateSaveStateCache();
|
|
||||||
} // namespace Host
|
} // namespace Host
|
||||||
|
|
|
@ -176,10 +176,6 @@ void Host::OnSaveStateSaved(const std::string_view& filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::InvalidateSaveStateCache()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Host::RunOnCPUThread(std::function<void()> function, bool block /* = false */)
|
void Host::RunOnCPUThread(std::function<void()> function, bool block /* = false */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue