From 0fd8188b67917406ea20d02b5f15754c249d6ff0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 7 Jul 2023 21:02:01 +0200 Subject: We need to be able to read the config even if the GPU options are not in it. --- src/lib/config.cc | 20 ++++++++++++-------- src/lib/config.h | 8 ++++---- src/lib/grok_context.h | 6 ++++-- src/wx/gpu_config_panel.cc | 4 ++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index 410b2a899..6cd1b54fc 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -216,9 +216,9 @@ Config::set_defaults () _gpu_binary_location = {}; _enable_gpu = false; _selected_gpu = 0; - _gpu_license_server = ""; + _gpu_license_server = {}; _gpu_license_port = 5000; - _gpu_license = ""; + _gpu_license = {}; _main_divider_sash_position = {}; _main_content_divider_sash_position = {}; @@ -643,10 +643,10 @@ try _enable_gpu = f.optional_bool_child("EnableGpu").get_value_or(false); _gpu_binary_location = f.optional_string_child("GpuBinaryLocation"); - _selected_gpu = f.number_child("SelectedGpu"); - _gpu_license_server = f.string_child("GpuLicenseServer"); - _gpu_license_port = f.number_child("GpuLicensePort"); - _gpu_license = f.string_child("GpuLicense"); + _selected_gpu = f.optional_number_child("SelectedGpu").get_value_or(0); + _gpu_license_server = f.optional_string_child("GpuLicenseServer"); + _gpu_license_port = f.optional_number_child("GpuLicensePort").get_value_or(5000); + _gpu_license = f.optional_string_child("GpuLicense"); _export.read(f.optional_node_child("Export")); } @@ -1139,9 +1139,13 @@ Config::write_config () const } root->add_child("EnableGpu")->add_child_text((_enable_gpu ? "1" : "0")); root->add_child("SelectedGpu")->add_child_text(raw_convert(_selected_gpu)); - root->add_child("GpuLicenseServer")->add_child_text(_gpu_license_server); + if (_gpu_license_server) { + root->add_child("GpuLicenseServer")->add_child_text(*_gpu_license_server); + } root->add_child("GpuLicensePort")->add_child_text(raw_convert(_gpu_license_port)); - root->add_child("GpuLicense")->add_child_text(_gpu_license); + if (_gpu_license) { + root->add_child("GpuLicense")->add_child_text(*_gpu_license); + } _export.write(root->add_child("Export")); diff --git a/src/lib/config.h b/src/lib/config.h index eb5e255a7..f3a35fa9b 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -630,7 +630,7 @@ public: return _selected_gpu; } - std::string gpu_license_server() const { + boost::optional gpu_license_server() const { return _gpu_license_server; } @@ -638,7 +638,7 @@ public: return _gpu_license_port; } - std::string gpu_license() const { + boost::optional gpu_license() const { return _gpu_license; } @@ -1496,9 +1496,9 @@ private: bool _enable_gpu; boost::optional _gpu_binary_location; int _selected_gpu; - std::string _gpu_license_server; + boost::optional _gpu_license_server; int _gpu_license_port; - std::string _gpu_license; + boost::optional _gpu_license; ExportConfig _export; diff --git a/src/lib/grok_context.h b/src/lib/grok_context.h index dcc40f237..e67591a48 100644 --- a/src/lib/grok_context.h +++ b/src/lib/grok_context.h @@ -260,6 +260,8 @@ public: _dcpomatic_context.set_dimensions(s.width, s.height); auto config = Config::instance(); DCPOMATIC_ASSERT(_dcpomatic_context.location); + DCPOMATIC_ASSERT(config->gpu_license_server()); + DCPOMATIC_ASSERT(config->gpu_license()); _messenger->launch_grok(*_dcpomatic_context.location, _dcpomatic_context.width, _dcpomatic_context.width, _dcpomatic_context.height, @@ -267,9 +269,9 @@ public: _dcpomatic_context.film->resolution() == Resolution::FOUR_K, _dcpomatic_context.film->video_frame_rate(), _dcpomatic_context.film->j2k_bandwidth(), - config->gpu_license_server(), + *config->gpu_license_server(), config->gpu_license_port(), - config->gpu_license()); + *config->gpu_license()); } _launched = _messenger->wait_for_client_init(); diff --git a/src/wx/gpu_config_panel.cc b/src/wx/gpu_config_panel.cc index 5d8365eb9..98e2faa98 100644 --- a/src/wx/gpu_config_panel.cc +++ b/src/wx/gpu_config_panel.cc @@ -198,9 +198,9 @@ GPUPage::config_changed() } _gpu_list_control->update(); _gpu_list_control->set_selection(config->selected_gpu()); - checked_set(_server, config->gpu_license_server()); + checked_set(_server, std_to_wx(config->gpu_license_server().get_value_or(""))); checked_set(_port, config->gpu_license_port()); - checked_set(_license, config->gpu_license()); + checked_set(_license, config->gpu_license().get_value_or("")); } -- cgit v1.2.3