Set up for the correct handling of UTF-8 with Windows
authorCarl Hetherington <cth@carlh.net>
Mon, 10 Aug 2015 21:13:22 +0000 (22:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 10 Aug 2015 21:44:31 +0000 (22:44 +0100)
paths before trying to access the config file.  Fixes #654.

src/lib/util.cc
src/lib/util.h
src/tools/dcpomatic.cc
src/tools/dcpomatic_batch.cc
src/tools/dcpomatic_cli.cc
src/tools/dcpomatic_create.cc
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_server.cc
src/tools/dcpomatic_server_cli.cc

index ede1d4e9b5c16bdee34c0c2ec7fd23db1e1bb7a2..56f1b528643226f21b4ffd671baccbf3601221ac 100644 (file)
@@ -280,18 +280,10 @@ terminate ()
        abort();
 }
 
-/** Call the required functions to set up DCP-o-matic's static arrays, etc.
- *  Must be called from the UI thread, if there is one.
- */
 void
-dcpomatic_setup ()
+dcpomatic_setup_path_encoding ()
 {
 #ifdef DCPOMATIC_WINDOWS
-       boost::filesystem::path p = g_get_user_config_dir ();
-       p /= "backtrace.txt";
-       set_backtrace_file (p);
-       SetUnhandledExceptionFilter(exception_handler);
-
        /* Dark voodoo which, I think, gets boost::filesystem::path to
           correctly convert UTF-8 strings to paths, and also paths
           back to UTF-8 strings (on path::string()).
@@ -307,6 +299,20 @@ dcpomatic_setup ()
        std::locale::global (boost::locale::generator().generate (""));
        boost::filesystem::path::imbue (std::locale ());
 #endif
+}
+
+/** Call the required functions to set up DCP-o-matic's static arrays, etc.
+ *  Must be called from the UI thread, if there is one.
+ */
+void
+dcpomatic_setup ()
+{
+#ifdef DCPOMATIC_WINDOWS
+       boost::filesystem::path p = g_get_user_config_dir ();
+       p /= "backtrace.txt";
+       set_backtrace_file (p);
+       SetUnhandledExceptionFilter(exception_handler);
+#endif
 
        avfilter_register_all ();
 
index be21fc89aaaefe91b62e12ba6ee92fe461346c62..95d272979f603e736d631a6b92d432683edb67dc 100644 (file)
@@ -65,6 +65,7 @@ extern std::string seconds_to_hms (int);
 extern std::string seconds_to_approximate_hms (int);
 extern double seconds (struct timeval);
 extern void dcpomatic_setup ();
+extern void dcpomatic_setup_path_encoding ();
 extern void dcpomatic_setup_gettext_i18n (std::string);
 extern std::string md5_digest_head_tail (std::vector<boost::filesystem::path>, boost::uintmax_t size);
 extern void ensure_ui_thread ();
index 6a743baa8ff407762021063eed39905187dc100b..cc85da0ef2faaa2b89aaea33c8d469198dd3dc45 100644 (file)
@@ -794,6 +794,8 @@ private:
 
                wxInitAllImageHandlers ();
 
+               dcpomatic_setup_path_encoding ();
+
                /* Enable i18n; this will create a Config object
                   to look for a force-configured language.  This Config
                   object will be wrong, however, because dcpomatic_setup
index 48ef8f798e1f413881032a9bd06b8ba7ea901799..8d787dd50192a58dde06efcef321210290a08ee9 100644 (file)
@@ -202,6 +202,8 @@ class App : public wxApp
                unsetenv ("UBUNTU_MENUPROXY");
 #endif
 
+               dcpomatic_setup_path_encoding ();
+
                /* Enable i18n; this will create a Config object
                   to look for a force-configured language.  This Config
                   object will be wrong, however, because dcpomatic_setup
index f885412efaf9d1ae0ebd7febd5cb7db5d3175d3e..2659b61bb4136c75410a8a2ed0856b6dd4a4b9d6 100644 (file)
@@ -177,6 +177,7 @@ main (int argc, char* argv[])
 
        film_dir = argv[optind];
 
+       dcpomatic_setup_path_encoding ();
        dcpomatic_setup ();
        signal_manager = new SignalManager ();
 
@@ -286,5 +287,3 @@ main (int argc, char* argv[])
 
        return error ? EXIT_FAILURE : EXIT_SUCCESS;
 }
-
-
index 6c479e698bff5911e29a202b1f4809de8d89a655..0130b518305802cfde764b8d4c6f191d94b0e488 100644 (file)
@@ -81,6 +81,7 @@ public:
 int
 main (int argc, char* argv[])
 {
+       dcpomatic_setup_path_encoding ();
        dcpomatic_setup ();
 
        string name;
index 0a43a91f28421f7b2d745882dfcd51a15a538f14..6f85f612760a5e567c6724fe1aff14009660e7b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -216,6 +216,7 @@ int main (int argc, char* argv[])
 
        string const film_dir = argv[optind];
 
+       dcpomatic_setup_path_encoding ();
        dcpomatic_setup ();
 
        shared_ptr<Film> film;
index 37eeb1e8e20d8966b68788d979e7f7d33c20c905..e10fd313814cdad562fcb84077e0f6c73934eaca 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -159,6 +159,7 @@ private:
                        return false;
                }
 
+               dcpomatic_setup_path_encoding ();
                dcpomatic_setup ();
 
                _icon = new TaskBarIcon;
index efcfdc40e340a251fdd22f9aa1cf6d2a236f797e..237673179a87074e35d3697e2a8dabcdb639f010 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -59,6 +59,9 @@ help (string n)
 int
 main (int argc, char* argv[])
 {
+       dcpomatic_setup_path_encoding ();
+       dcpomatic_setup ();
+
        int num_threads = Config::instance()->num_local_encoding_threads ();
        bool verbose = false;
        bool write_log = false;