Allow to revert export-format from disk
authorRobin Gareus <robin@gareus.org>
Wed, 21 Nov 2018 22:14:52 +0000 (23:14 +0100)
committerRobin Gareus <robin@gareus.org>
Wed, 21 Nov 2018 22:14:52 +0000 (23:14 +0100)
This allows to restore ProfileManager's ExportFormatSpec without
re-instantiating the ProfileManager.

libs/ardour/ardour/export_profile_manager.h
libs/ardour/export_profile_manager.cc

index 4f477f65b9a4632734949b2e31aca98b83bb7e92..a2685fa19959f9e411558041babbbaba1f450586 100644 (file)
@@ -205,6 +205,7 @@ class LIBARDOUR_API ExportProfileManager
 
        std::string save_format_to_disk (ExportFormatSpecPtr format);
        void remove_format_profile (ExportFormatSpecPtr format);
+       void revert_format_profile (ExportFormatSpecPtr format);
        ExportFormatSpecPtr get_new_format (ExportFormatSpecPtr original);
 
        PBD::Signal0<void> FormatListChanged;
index 14c57436ab4b51d56dd8be99cf255f1f7abe3f48..877b4343774e825555e20991b196f539019a7e98 100644 (file)
@@ -661,6 +661,23 @@ ExportProfileManager::remove_format_profile (ExportFormatSpecPtr format)
        FormatListChanged ();
 }
 
+void
+ExportProfileManager::revert_format_profile (ExportFormatSpecPtr format)
+{
+       FileMap::iterator it;
+       if ((it = format_file_map.find (format->id())) == format_file_map.end()) {
+               return;
+       }
+
+       XMLTree tree;
+       if (!tree.read (it->second.c_str())) {
+               return;
+       }
+
+       format->set_state (*tree.root());
+       FormatListChanged ();
+}
+
 ExportFormatSpecPtr
 ExportProfileManager::get_new_format (ExportFormatSpecPtr original)
 {