1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 07:43:01 +01:00

Fix #5521: Infinite loop on first run if neither Zenity nor kdialog are installed (#5526)

This commit is contained in:
Ted John
2017-06-03 22:13:20 +01:00
committed by GitHub
parent 810d46055a
commit af91b9f4b4
3 changed files with 69 additions and 34 deletions

View File

@@ -124,8 +124,10 @@ namespace OpenRCT2
sint32 RunOpenRCT2(int argc, char * * argv) override
{
Initialise();
Launch();
if (Initialise())
{
Launch();
}
return gExitCode;
}
@@ -677,26 +679,43 @@ extern "C"
bool platform_open_common_file_dialog(utf8 * outFilename, file_dialog_desc * desc, size_t outSize)
{
FileDialogDesc desc2;
desc2.Type = (FILE_DIALOG_TYPE)desc->type;
desc2.Title = String::ToStd(desc->title);
desc2.InitialDirectory = String::ToStd(desc->initial_directory);
desc2.DefaultFilename = String::ToStd(desc->default_filename);
for (const auto &filter : desc->filters)
try
{
if (filter.name != nullptr)
FileDialogDesc desc2;
desc2.Type = (FILE_DIALOG_TYPE)desc->type;
desc2.Title = String::ToStd(desc->title);
desc2.InitialDirectory = String::ToStd(desc->initial_directory);
desc2.DefaultFilename = String::ToStd(desc->default_filename);
for (const auto &filter : desc->filters)
{
desc2.Filters.push_back({ String::ToStd(filter.name), String::ToStd(filter.pattern) });
if (filter.name != nullptr)
{
desc2.Filters.push_back({ String::ToStd(filter.name), String::ToStd(filter.pattern) });
}
}
std::string result = GetContext()->GetUiContext()->ShowFileDialog(desc2);
String::Set(outFilename, outSize, result.c_str());
return !result.empty();
}
catch (const std::exception &ex)
{
log_error(ex.what());
outFilename[0] = '\0';
return false;
}
std::string result = GetContext()->GetUiContext()->ShowFileDialog(desc2);
String::Set(outFilename, outSize, result.c_str());
return !result.empty();
}
utf8 * platform_open_directory_browser(const utf8 * title)
{
std::string result = GetContext()->GetUiContext()->ShowDirectoryDialog(title);
return String::Duplicate(result.c_str());
try
{
std::string result = GetContext()->GetUiContext()->ShowDirectoryDialog(title);
return String::Duplicate(result.c_str());
}
catch (const std::exception &ex)
{
log_error(ex.what());
return nullptr;
}
}
}