13
0

Fix XML read error when creating new export profiles

Previously creating a new preset first attempted to load
it from disk, before creating it. This resulted in a
`XML error: failed to load external entity`.
This commit is contained in:
Robin Gareus 2023-09-25 20:14:54 +02:00
parent b711da9153
commit 300de26b3e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 16 additions and 10 deletions

View File

@ -35,7 +35,7 @@ class Session;
class LIBARDOUR_API ExportPreset { class LIBARDOUR_API ExportPreset {
public: public:
ExportPreset (std::string filename, Session & s); ExportPreset (Session&, std::string const& filename = "");
~ExportPreset (); ~ExportPreset ();
PBD::UUID const & id () const { return _id; } PBD::UUID const & id () const { return _id; }

View File

@ -26,12 +26,19 @@
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
ExportPreset::ExportPreset (string filename, Session & s) : ExportPreset::ExportPreset (Session& s, string const& filename)
session (s), global (filename), local (0) : session (s)
, local (0)
{ {
XMLNode * root; if (filename.empty ()) {
std::string str; return;
}
global.read (filename);
XMLNode* root;
if ((root = global.root())) { if ((root = global.root())) {
std::string str;
if (root->get_property ("id", str)) { if (root->get_property ("id", str)) {
set_id (str); set_id (str);
} }

View File

@ -227,9 +227,8 @@ ExportProfileManager::preset_filename (std::string const& preset_name)
ExportPresetPtr ExportPresetPtr
ExportProfileManager::new_preset (string const& name) ExportProfileManager::new_preset (string const& name)
{ {
// Generate new ID and do regular save // Generate new and do regular save
string filename = preset_filename (name); current_preset.reset (new ExportPreset (session));
current_preset.reset (new ExportPreset (filename, session));
preset_list.push_back (current_preset); preset_list.push_back (current_preset);
return save_preset (name); return save_preset (name);
} }
@ -240,7 +239,7 @@ ExportProfileManager::save_preset (string const& name)
string filename = preset_filename (name); string filename = preset_filename (name);
if (!current_preset) { if (!current_preset) {
current_preset.reset (new ExportPreset (filename, session)); current_preset.reset (new ExportPreset (session, filename));
preset_list.push_back (current_preset); preset_list.push_back (current_preset);
} }
@ -288,7 +287,7 @@ ExportProfileManager::remove_preset ()
void void
ExportProfileManager::load_preset_from_disk (std::string const& path) ExportProfileManager::load_preset_from_disk (std::string const& path)
{ {
ExportPresetPtr preset (new ExportPreset (path, session)); ExportPresetPtr preset (new ExportPreset (session, path));
/* Handle id to filename mapping and don't add duplicates to list */ /* Handle id to filename mapping and don't add duplicates to list */