From 1dffd2a2fe8b2c0835460b84fd63fd19aa74d890 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 1 Oct 2021 18:21:05 +0300 Subject: SL-13934 Crash at saveToFile #2 More detailed stream handling and logging --- indra/newview/llinventorymodel.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 5abc335d39..72281d9e4c 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -2808,13 +2808,19 @@ bool LLInventoryModel::saveToFile(const std::string& filename, llofstream fileXML(filename.c_str()); if (!fileXML.is_open()) { - LL_WARNS(LOG_INV) << "unable to save inventory to: " << filename << LL_ENDL; + LL_WARNS(LOG_INV) << "Failed to open file. Unable to save inventory to: " << filename << LL_ENDL; return false; } LLSD cache_ver; cache_ver["inv_cache_version"] = sCurrentInvCacheVersion; + if (fileXML.fail()) + { + LL_WARNS(LOG_INV) << "Failed to write cache version to file. Unable to save inventory to: " << filename << LL_ENDL; + return false; + } + fileXML << LLSDOStreamer(cache_ver) << std::endl; S32 count = categories.size(); @@ -2828,12 +2834,24 @@ bool LLInventoryModel::saveToFile(const std::string& filename, fileXML << LLSDOStreamer(cat->exportLLSD()) << std::endl; cat_count++; } + + if (fileXML.fail()) + { + LL_WARNS(LOG_INV) << "Failed to write a folder to file. Unable to save inventory to: " << filename << LL_ENDL; + return false; + } } S32 it_count = items.size(); for (i = 0; i < it_count; ++i) { fileXML << LLSDOStreamer(items[i]->asLLSD()) << std::endl; + + if (fileXML.fail()) + { + LL_WARNS(LOG_INV) << "Failed to write an item to file. Unable to save inventory to: " << filename << LL_ENDL; + return false; + } } fileXML.close(); -- cgit v1.2.3