Skip to content

Commit

Permalink
Fix crash upon selecting a stamp too quickly
Browse files Browse the repository at this point in the history
SaveButton relies on the SaveFile/SaveInfo passed to it at construction being alive until its destruction, or at least while it's being ticked (while its Tick is being called). While SaveButtons are owned by views, SaveFiles/SaveInfos associated with them are owned by models, so models need to immediately notify views (their observers) of changes made to SaveFiles/SaveInfos, or otherwise prevent views (and thus SaveButtons) from accessing stale SaveFile/SaveInfo pointers.

The online save browser model (SearchModel) correctly notifies its observer (SearchView) about changes to its list of SaveInfos. The local save browser (FileBrowserActivity) is not MVC and simply either fully exits when its SaveFile list changes, or it cleans up its SaveButtons beforehand. The stamp browser model (LocalBrowerModel), however, would make changes to its SaveFile list without notifying its observer (LocalBrowserView) when selecting a stamp, so the latter might tick its SaveButtons after SaveFiles associated with them had already been cleaned up. This commit adds the missing notification.

The crash would manifest when the SaveFile associated with a stamp was accessed for the GameSave it owned to be sent off for rendering with ThumbnailRendererTask.
  • Loading branch information
LBPHacker committed Mar 24, 2024
1 parent c1c1daa commit d56e838
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gui/localbrowser/LocalBrowserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void LocalBrowserModel::OpenSave(int index)
{
stamp = std::move(savesList[index]);
savesList.clear();
notifyPageChanged();
notifySavesListChanged();
}

bool LocalBrowserModel::GetMoveToFront()
Expand Down

0 comments on commit d56e838

Please sign in to comment.