From 3eb56c2343e123e20a7cf6864568819f915eb003 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 30 Apr 2008 21:23:42 +0000 Subject: Fix Redland NULL node assertion failures when saving. git-svn-id: http://svn.drobilla.net/lad/ingen@1184 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/serialisation/Serialiser.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/libs/serialisation/Serialiser.cpp') diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp index d6bd1df4..d3114082 100644 --- a/src/libs/serialisation/Serialiser.cpp +++ b/src/libs/serialisation/Serialiser.cpp @@ -432,14 +432,23 @@ Serialiser::serialise_variables(Redland::Node subject, const GraphObject::Variab { for (GraphObject::Variables::const_iterator v = variables.begin(); v != variables.end(); ++v) { if (v->first.find(":") != string::npos) { + if (v->second) { const Redland::Node var_id = _world.blank_id(); const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first); - _model->add_statement(subject, "ingen:variable", var_id); - _model->add_statement(var_id, "ingen:key", key); - _model->add_statement(var_id, "ingen:value", - AtomRDF::atom_to_node(_model->world(), v->second)); + const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second); + if (value) { + _model->add_statement(subject, "ingen:variable", var_id); + _model->add_statement(var_id, "ingen:key", key); + _model->add_statement(var_id, "ingen:value", value); + } else { + cerr << "Warning: can not serialise value: key '" << v->first << "', type " + << (int)v->second.type() << endl; + } + } else { + cerr << "Warning: variable with no value: key '" << v->first << "'" << endl; + } } else { - cerr << "Warning: not serialising variable with key '" << v->first << "'" << endl; + cerr << "Warning: not serialising variable with invalid key '" << v->first << "'" << endl; } } } -- cgit v1.2.1