From 430711a33b5be35ad65a84865fbfe3cf01721d47 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sat, 20 Mar 2021 14:51:15 +0100 Subject: [PATCH] Cache HasFilePicker() value in UiContext --- distribution/changelog.txt | 1 + src/openrct2-ui/UiContext.Linux.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 609d681983..2caac7d065 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -3,6 +3,7 @@ - Feature: [#14071] “Vandals stopped” statistic for security guards. - Feature: [#14296] Allow using early scenario completion in multiplayer. - Fix: [#11829] Visual glitches and crashes when using RCT1 assets from mismatched or corrupt CSG1.DAT and CSG1i.DAT files. +- Fix: [#13581] Opening the Options menu causes a noticeable drop in FPS. - Fix: [#13894] Block brakes do not animate. - Fix: [#14315] Crash when trying to rename Air Powered Vertical Coaster in Korean. - Fix: [#14330] join_server uses default_port from config. diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index 3eacd67048..8c31867de2 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -35,6 +35,8 @@ namespace OpenRCT2::Ui class LinuxContext final : public IPlatformUiContext { private: + mutable std::optional _hasFilePicker = std::nullopt; + public: LinuxContext() { @@ -253,8 +255,13 @@ namespace OpenRCT2::Ui bool HasFilePicker() const override { - std::string dummy; - return GetDialogApp(&dummy) != DIALOG_TYPE::NONE; + if (!_hasFilePicker.has_value()) + { + std::string dummy; + _hasFilePicker = (GetDialogApp(&dummy) != DIALOG_TYPE::NONE); + } + + return _hasFilePicker.value(); } bool HasMenuSupport() override