Skip to content

Commit 1659c72

Browse files
committed
gcc 14:
- fix some more compilation errors, use after destroy
1 parent 29eafe6 commit 1659c72

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/scenes/recording_selector/recording_selector.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,24 @@ namespace scenes {
7575
if (m_next_command.has_value()) {
7676
return std::visit(
7777
helper::overloaded{
78-
[](const Return&) {
79-
return UpdateResult{ SceneUpdate::StopUpdating, Scene::Pop{} };
80-
},
78+
[](const Return&) { return UpdateResult{ SceneUpdate::StopUpdating, Scene::Pop{} }; },
8179
[this](const Action& action) {
82-
m_next_command = helper::nullopt;
83-
8480
if (auto* recording_component =
8581
dynamic_cast<custom_ui::RecordingComponent*>(action.widget);
8682
recording_component != nullptr) {
8783

8884
const auto recording_path = recording_component->metadata().path;
8985

86+
// action is a reference to a structure inside m_next_command, so resetting it means, we need to copy everything out of it
87+
m_next_command = helper::nullopt;
88+
9089
return UpdateResult{
9190
SceneUpdate::StopUpdating,
92-
Scene::RawSwitch{"ReplayGame",
91+
Scene::RawSwitch{ "ReplayGame",
9392
std::make_unique<ReplayGame>(
94-
m_service_provider, ui::FullScreenLayout{ m_service_provider->window() },
93+
m_service_provider, ui::FullScreenLayout{ m_service_provider->window() },
9594
recording_path
96-
)}
95+
) }
9796
};
9897
}
9998
#if defined(_HAVE_FILE_DIALOGS)
@@ -108,6 +107,9 @@ namespace scenes {
108107

109108
add_all_recordings();
110109

110+
// action is a reference to a structure inside m_next_command, so resetting it means, we need to copy everything out of it
111+
m_next_command = helper::nullopt;
112+
111113
return UpdateResult{ SceneUpdate::StopUpdating, helper::nullopt };
112114
}
113115

src/scenes/settings_menu/settings_menu.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@ namespace scenes {
115115
return UpdateResult{ SceneUpdate::StopUpdating, Scene::Pop{} };
116116
},
117117
[this](const Action& action) {
118-
m_next_command = helper::nullopt;
119-
120118
if (auto* settings_details = dynamic_cast<settings::SettingsDetails*>(action.widget);
121119
settings_details != nullptr) {
122120

123121
auto change_scene = settings_details->get_details_scene();
124122

123+
// action is a reference to a structure inside m_next_command, so resetting it means, we need to copy everything out of it
124+
m_next_command = helper::nullopt;
125+
125126
return UpdateResult{ SceneUpdate::StopUpdating, std::move(change_scene) };
126127
}
127128

@@ -151,7 +152,7 @@ namespace scenes {
151152
if (const auto event_result = m_main_layout.handle_event(event, window); event_result) {
152153
if (const auto additional = event_result.get_additional();
153154
additional.has_value() and additional.value().first == ui::EventHandleType::RequestAction) {
154-
m_next_command = Command{ Action(additional.value().second) };
155+
m_next_command = Command{ Action{ additional.value().second } };
155156
}
156157

157158
return true;

0 commit comments

Comments
 (0)