[PR #845] [MERGED] Fix issues with a -resume parameter #160

Closed
opened 2026-01-29 19:06:41 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/stenzek/duckstation/pull/845
Author: @CookiePLMonster
Created: 9/12/2020
Status: Merged
Merged: 9/13/2020
Merged by: @stenzek

Base: masterHead: fix-resume


📝 Commits (3)

  • 95d5417 Fix -resume causing a quiet exit if there is no resume savestate
  • c47dcef Pass a SystemBootParameters pointer to QtHostInterface::bootSystem
  • 2d90cfc Tidy up SystemBootParameters constructors

📊 Changes

7 files changed (+33 additions, -43 deletions)

View changed files

📝 src/core/system.cpp (+2 -7)
📝 src/core/system.h (+1 -1)
📝 src/duckstation-qt/main.cpp (+2 -3)
📝 src/duckstation-qt/mainwindow.cpp (+12 -16)
📝 src/duckstation-qt/qthostinterface.cpp (+5 -10)
📝 src/duckstation-qt/qthostinterface.h (+2 -4)
📝 src/frontend-common/common_host_interface.cpp (+9 -2)

📄 Description

This PR fixes two issues related to the -resume parameter:

  1. When DuckStation is launched with any of the parameters indicating that a save state should be loaded and this save state didn't exist, it would exit quietly. This makes sense when an explicit path to the save state is passed, but not when resuming. A resume save state has been special cased not to terminate DS if it doesn't exist.
  2. The case where -resume was passed and a save state exists would hit an assertion in the copy constructor of SystemBootParameters because an attempt to copy a byte stream pointer was being made. This comes from an invokeMethod function used to marshal the call to a Qt worker thread, which as per Qt rules ends up serializing parameters by value, even if they were passed by reference. As a result, SystemBootParameters was being copied around, even though it's been clearly designed to be a non-copyable class. I have modified bootSystem to operate on a std::shared_ptr<SystemBootParameters>, which avoids any copies on the object itself. It's technically also more correct, because this object does have to be copied around, and thus a shared pointer makes sense.

As a nice side-effect of those two changes, I tidied up SystemBootParameters constructors to move a string instead of copying it, and also made the object truly non-copyable.

Fixes #827


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/stenzek/duckstation/pull/845 **Author:** [@CookiePLMonster](https://github.com/CookiePLMonster) **Created:** 9/12/2020 **Status:** ✅ Merged **Merged:** 9/13/2020 **Merged by:** [@stenzek](https://github.com/stenzek) **Base:** `master` ← **Head:** `fix-resume` --- ### 📝 Commits (3) - [`95d5417`](https://github.com/stenzek/duckstation/commit/95d54170176086dbf710a0399d36661b634740d0) Fix -resume causing a quiet exit if there is no resume savestate - [`c47dcef`](https://github.com/stenzek/duckstation/commit/c47dceffb59db6ec1366b422bfc7d5698278f78a) Pass a SystemBootParameters pointer to QtHostInterface::bootSystem - [`2d90cfc`](https://github.com/stenzek/duckstation/commit/2d90cfc07e662c92430581ea5970543d52e3f082) Tidy up SystemBootParameters constructors ### 📊 Changes **7 files changed** (+33 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `src/core/system.cpp` (+2 -7) 📝 `src/core/system.h` (+1 -1) 📝 `src/duckstation-qt/main.cpp` (+2 -3) 📝 `src/duckstation-qt/mainwindow.cpp` (+12 -16) 📝 `src/duckstation-qt/qthostinterface.cpp` (+5 -10) 📝 `src/duckstation-qt/qthostinterface.h` (+2 -4) 📝 `src/frontend-common/common_host_interface.cpp` (+9 -2) </details> ### 📄 Description This PR fixes two issues related to the `-resume` parameter: 1. When DuckStation is launched with any of the parameters indicating that a save state should be loaded **and** this save state didn't exist, it would exit quietly. This makes sense when an explicit path to the save state is passed, but not when resuming. A resume save state has been special cased not to terminate DS if it doesn't exist. 2. The case where `-resume` was passed and a save state exists would hit an assertion in the copy constructor of `SystemBootParameters` because an attempt to copy a byte stream pointer was being made. This comes from an `invokeMethod` function used to marshal the call to a Qt worker thread, which as per Qt rules ends up serializing parameters by value, even if they were passed by reference. As a result, `SystemBootParameters` was being copied around, even though it's been clearly designed to be a non-copyable class. I have modified `bootSystem` to operate on a `std::shared_ptr<SystemBootParameters>`, which avoids any copies on the object itself. It's technically also more correct, because this object **does** have to be copied around, and thus a shared pointer makes sense. As a nice side-effect of those two changes, I tidied up `SystemBootParameters` constructors to move a string instead of copying it, and also made the object truly non-copyable. Fixes #827 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 19:06:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/duckstation#160