summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-07-07 21:02:01 +0200
committerCarl Hetherington <cth@carlh.net>2023-07-07 21:02:01 +0200
commit0fd8188b67917406ea20d02b5f15754c249d6ff0 (patch)
treebe81d5a820c5c23aa3066c7eccfee5f27ebd4115
parent3fb07619cdc215007ae791833e7a101682b4323b (diff)
We need to be able to read the config even if the GPU options are not in it.
-rw-r--r--src/lib/config.cc20
-rw-r--r--src/lib/config.h8
-rw-r--r--src/lib/grok_context.h6
-rw-r--r--src/wx/gpu_config_panel.cc4
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<int>("SelectedGpu");
- _gpu_license_server = f.string_child("GpuLicenseServer");
- _gpu_license_port = f.number_child<int>("GpuLicensePort");
- _gpu_license = f.string_child("GpuLicense");
+ _selected_gpu = f.optional_number_child<int>("SelectedGpu").get_value_or(0);
+ _gpu_license_server = f.optional_string_child("GpuLicenseServer");
+ _gpu_license_port = f.optional_number_child<int>("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<string>(_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<string>(_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<std::string> gpu_license_server() const {
return _gpu_license_server;
}
@@ -638,7 +638,7 @@ public:
return _gpu_license_port;
}
- std::string gpu_license() const {
+ boost::optional<std::string> gpu_license() const {
return _gpu_license;
}
@@ -1496,9 +1496,9 @@ private:
bool _enable_gpu;
boost::optional<boost::filesystem::path> _gpu_binary_location;
int _selected_gpu;
- std::string _gpu_license_server;
+ boost::optional<std::string> _gpu_license_server;
int _gpu_license_port;
- std::string _gpu_license;
+ boost::optional<std::string> _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(""));
}