From 03f292e34b61ef95cafd9be90d8471eb4f9bfca9 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 22 Oct 2018 17:04:25 +0300 Subject: [PATCH] Small optimization of compressing --- src/XGUI/XGUI_CompressFiles.cpp | 7 +++---- src/XGUI/XGUI_Workshop.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/XGUI/XGUI_CompressFiles.cpp b/src/XGUI/XGUI_CompressFiles.cpp index 49682b461..ebcddc95f 100644 --- a/src/XGUI/XGUI_CompressFiles.cpp +++ b/src/XGUI/XGUI_CompressFiles.cpp @@ -38,14 +38,13 @@ bool XGUI_CompressFiles::compress(const QString& theFile, std::list for (aIt = theFiles.cbegin(); aIt != theFiles.cend(); ++aIt) { QString aPathName((*aIt).c_str()); QFile aSrcFile(aPathName); + QFileInfo aInfo(aSrcFile); + quint64 aSize = aInfo.size(); if (aSrcFile.open(QIODevice::ReadOnly)) { - QFileInfo aInfo(aSrcFile); - quint64 aSize = aInfo.size(); QString aName = aPathName.right(aPathName.length() - aPathName.lastIndexOf(QDir::separator()) - 1); - aOutStream << aName << aSize; - aOutStream << qCompress(aSrcFile.readAll()); + aOutStream << aName << aSize << qCompress(aSrcFile.readAll()); aSrcFile.close(); } else { diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 735d8d516..a9e69145c 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -947,7 +947,8 @@ void XGUI_Workshop::openFile(const QString& theDirectory) aSession->closeAll(); clearTemporaryDir(); - XGUI_CompressFiles::uncompress(myCurrentFile, myTmpDir.path()); + if (!XGUI_CompressFiles::uncompress(myCurrentFile, myTmpDir.path())) + return; aSession->load(myTmpDir.path().toLatin1().constData()); myObjectBrowser->rebuildDataTree(); @@ -1065,7 +1066,8 @@ bool XGUI_Workshop::onSave() std::list aFiles; saveDocument(myTmpDir.path(), aFiles); - XGUI_CompressFiles::compress(myCurrentFile, aFiles); + if (!XGUI_CompressFiles::compress(myCurrentFile, aFiles)) + return false; updateCommandStatus(); #ifndef HAVE_SALOME -- 2.39.2