From b00f7127a9f07caedc09f6aa1a8bfb72895d39e2 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 11 Mar 2020 10:20:27 +0100 Subject: [PATCH] Open app prefs: avoid erasing a user custom value while applying changes when there is no recoll default: the mime would completely disappear from the list --- src/qtgui/viewaction_w.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/qtgui/viewaction_w.cpp b/src/qtgui/viewaction_w.cpp index 89fcd042..a84259f8 100644 --- a/src/qtgui/viewaction_w.cpp +++ b/src/qtgui/viewaction_w.cpp @@ -207,8 +207,19 @@ void ViewAction::editActions() } } // An empty action will restore the default (erase from - // topmost conftree) + // topmost conftree). IF there is no default in the system + // files, and the entry only came from the user file, it will + // be erased and the mime will go away from the list, which is + // not what we want ! This not trivial to test because + // rclconfig has no way to tell us if the value comes from the + // system config or the user file. So just check if the value + // disappears after setting it, and restore it if it does. + string oldvalue = theconfig->getMimeViewerDef(entry, "", 0); theconfig->setMimeViewerDef(entry, sact); + string newvalue = theconfig->getMimeViewerDef(entry, "", 0); + if (!oldvalue.empty() && newvalue.empty()) { + theconfig->setMimeViewerDef(entry, oldvalue); + } } theconfig->setMimeViewerAllEx(viewerXs);