13
0

Prevent libXML read error in case file does not exist

This commit is contained in:
Robin Gareus 2021-04-19 04:55:17 +02:00
parent 71788ecfe4
commit 905ea49f05
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <glib.h> #include <glibmm.h>
#include "pbd/gstdio_compat.h" #include "pbd/gstdio_compat.h"
#include <glibmm/miscutils.h> #include <glibmm/miscutils.h>
@ -131,7 +131,7 @@ ALoudnessPresets::ALoudnessPresets (bool built_in_only)
} }
std::string fn = Glib::build_filename (ARDOUR::user_config_directory (), "loudness-presets"); std::string fn = Glib::build_filename (ARDOUR::user_config_directory (), "loudness-presets");
XMLTree tree; XMLTree tree;
if (tree.read (fn)) { if (Glib::file_test (fn, Glib::FILE_TEST_EXISTS) && tree.read (fn)) {
XMLNodeList nlist = tree.root()->children(); XMLNodeList nlist = tree.root()->children();
XMLNodeConstIterator i; XMLNodeConstIterator i;
for (i = nlist.begin(); i != nlist.end(); ++i) { for (i = nlist.begin(); i != nlist.end(); ++i) {