diff --git a/xLights/TabSequence.cpp b/xLights/TabSequence.cpp index e94f7c2ac..c9cd58b7e 100644 --- a/xLights/TabSequence.cpp +++ b/xLights/TabSequence.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include "xLightsMain.h" #include "SeqSettingsDialog.h" @@ -713,15 +714,28 @@ bool xLightsFrame::SaveEffectsFile(bool backup) effectsFile.SetFullName(_(XLIGHTS_RGBEFFECTS_FILE)); } - if (!EffectsXml.Save(effectsFile.GetFullPath())) { + wxFileOutputStream fout(effectsFile.GetFullPath()); + wxBufferedOutputStream *bout = new wxBufferedOutputStream(fout, 2 * 1024 * 1024); + + if (!EffectsXml.Save(*bout)) { if (backup) { logger_base.warn("Unable to save backup of RGB effects file"); } else { DisplayError("Unable to save RGB effects file", this); } + delete bout; return false; } - + delete bout; + if (!fout.Close()) { + if (backup) { + logger_base.warn("Unable to save backup of RGB effects file"); + } else { + DisplayError("Unable to save RGB effects file", this); + } + return false; + } + if (!backup) { #ifndef __WXOSX__ SaveModelsFile(); diff --git a/xLights/outputs/OutputManager.cpp b/xLights/outputs/OutputManager.cpp index 19787851f..72c5cc363 100644 --- a/xLights/outputs/OutputManager.cpp +++ b/xLights/outputs/OutputManager.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "IPOutput.h" #include "OutputManager.h" @@ -429,9 +430,15 @@ bool OutputManager::Save() { root->AddChild(it->Save()); } - if (doc.Save(_filename)) { + wxFileOutputStream fout(_filename); + wxBufferedOutputStream *bout = new wxBufferedOutputStream(fout, 2 * 1024 * 1024); + if (doc.Save(*bout)) { _dirty = false; } + delete bout; + if (!fout.Close()) { + _dirty = true; + } return (_dirty == false); } diff --git a/xLights/xLightsXmlFile.cpp b/xLights/xLightsXmlFile.cpp index ffc4bb08d..b17d904d4 100644 --- a/xLights/xLightsXmlFile.cpp +++ b/xLights/xLightsXmlFile.cpp @@ -2861,9 +2861,17 @@ bool xLightsXmlFile::Save(SequenceElements& seq_elements) } #endif - if (!seqDocument.Save(GetFullPath())) { + wxFileOutputStream fout(GetFullPath()); + wxBufferedOutputStream *bout = new wxBufferedOutputStream(fout, 2 * 1024 * 1024); + if (!seqDocument.Save(*bout)) { + delete bout; return false; } + delete bout; + if (!fout.Close()) { + return false; + } + MarkNewFileRevision(GetFullPath()); return true; }