Fix #8841: Catch exceptions when loading parks from title editor (#8843)

This commit is contained in:
Ted John 2019-03-11 16:31:02 +00:00 committed by GitHub
parent 25eb403c78
commit 85c1ec8fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 12 deletions

View File

@ -363,8 +363,9 @@ static void window_title_editor_mouseup(rct_window* w, rct_widgetindex widgetInd
auto handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
auto stream = (IStream*)handle->Stream;
auto hintPath = String::ToStd(handle->HintPath);
bool isScenario = ParkImporter::ExtensionIsScenario(hintPath);
try
{
auto& objectMgr = OpenRCT2::GetContext()->GetObjectManager();
auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
auto result = parkImporter->LoadFromStream(stream, isScenario);
@ -379,6 +380,11 @@ static void window_title_editor_mouseup(rct_window* w, rct_widgetindex widgetInd
TitleSequenceCloseParkHandle(handle);
window_title_editor_open(WINDOW_TITLE_EDITOR_TAB_SAVES);
}
catch (const std::exception&)
{
context_show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
}
}
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////