From 732316dcafc1fdb16ea27c0c5af1707dffcd80b4 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Tue, 5 Oct 2021 21:49:42 -0700 Subject: [PATCH] Fix initial generation of external editor icons In Windows, escape backslashes and quotes in the serialized GVariants of the icons. --- rtgui/options.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rtgui/options.cc b/rtgui/options.cc index 53cedea95..a6b693f53 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -904,7 +904,16 @@ void Options::readFromFile(Glib::ustring fname) #ifdef WIN32 auto getIconSerialized = [](const Glib::ustring &executable) { - return Glib::ustring::compose("('themed', <['%1,0', '%1,0-symbolic']>)", executable); + // Backslashes and quotes must be escaped in the text representation of GVariant strings. + // See https://www.freedesktop.org/software/gstreamer-sdk/data/docs/2012.5/glib/gvariant-text.html#gvariant-text-strings + Glib::ustring exec_escaped = ""; + for (const auto character : executable) { + if (character == '\\' || character == '\'') { + exec_escaped += '\\'; + } + exec_escaped += character; + } + return Glib::ustring::compose("('themed', <['%1,0', '%1,0-symbolic']>)", exec_escaped); }; Glib::ustring gimpDir = ""; if (keyFile.has_key("External Editor", "GimpDir")) {