We need to be able to read the config even if the GPU options are not in it.
authorCarl Hetherington <cth@carlh.net>
Fri, 7 Jul 2023 19:02:01 +0000 (21:02 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 Jul 2023 19:02:01 +0000 (21:02 +0200)
src/lib/config.cc
src/lib/config.h
src/lib/grok_context.h
src/wx/gpu_config_panel.cc

index 410b2a899d4f7173a0106357f3d634628f4005f8..6cd1b54fc2f737140a766e94237fb7b0d7e93230 100644 (file)
@@ -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"));
 
index eb5e255a719d3bd94ab832e6a63b02bd3f801497..f3a35fa9bb1bd63861113c01ec87d6d71c682d79 100644 (file)
@@ -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;
 
index dcc40f237c915279b78ac07c7fa4f8db852199f7..e67591a48cae13d7ca9ca4aca845dbbbfa4db97c 100644 (file)
@@ -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();
 
index 5d8365eb9bf7defd6b5cb1d4f4839c4c16bdfd0a..98e2faa98de337dbf7fa67f40f11301fb5eca472 100644 (file)
@@ -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(""));
 }