Skip to content

Commit 97722ba

Browse files
committed
Closes #1489
1 parent 3705e4c commit 97722ba

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Dataflow/Serialization/Network/XMLSerializer.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@ namespace Networks {
4747
namespace XMLSerializer
4848
{
4949
template <class Serializable>
50-
void save_xml(const Serializable& data, std::ostream& ostr, const std::string& rootName)
50+
bool save_xml(const Serializable& data, std::ostream& ostr, const std::string& rootName)
5151
{
5252
if (!ostr.good())
53-
return;
53+
return false;
5454
boost::archive::xml_oarchive oa(ostr);
5555
oa << boost::serialization::make_nvp(rootName.c_str(), data);
56+
return true;
5657
}
5758

5859
template <class Serializable>
59-
void save_xml(const Serializable& data, const std::string& filename, const std::string& rootName)
60+
bool save_xml(const Serializable& data, const std::string& filename, const std::string& rootName)
6061
{
6162
std::ofstream ofs(filename.c_str());
62-
save_xml(data, ofs, rootName);
63+
if (!ofs)
64+
return false;
65+
return save_xml(data, ofs, rootName);
6366
}
6467

6568
template <class Serializable>
6669
boost::shared_ptr<Serializable> load_xml(std::istream& istr)
6770
{
6871
if (!istr.good())
69-
return boost::shared_ptr<Serializable>();
72+
return nullptr;
7073
boost::archive::xml_iarchive ia(istr);
7174
boost::shared_ptr<Serializable> nh(new Serializable);
7275
ia >> BOOST_SERIALIZATION_NVP(*nh);

src/Interface/Application/GuiCommands.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ bool NetworkSaveCommand::execute()
300300

301301
auto file = Application::Instance().controller()->saveNetwork();
302302

303-
XMLSerializer::save_xml(*file, fileNameWithExtension, "networkFile");
303+
if (!XMLSerializer::save_xml(*file, fileNameWithExtension, "networkFile"))
304+
return false;
304305
SCIRunMainWindow::Instance()->setCurrentFile(QString::fromStdString(fileNameWithExtension));
305306

306307
SCIRunMainWindow::Instance()->statusBar()->showMessage("File saved: " + QString::fromStdString(filename), 2000);

0 commit comments

Comments
 (0)