From 131449d164331c00a5be5f83ccc2aecec6778e82 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 30 May 2019 15:28:28 +0300 Subject: [PATCH] Improve the coverage level. --- src/Events/Events_InfoMessage.cpp | 14 ++++++-------- src/Events/Events_Loop.cpp | 8 ++++---- .../ExchangePlugin_ExportFeature.cpp | 18 ++++-------------- src/ModelAPI/ModelAPI_Result.cpp | 2 +- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/Events/Events_InfoMessage.cpp b/src/Events/Events_InfoMessage.cpp index f85bed868..a9b3cd3fb 100644 --- a/src/Events/Events_InfoMessage.cpp +++ b/src/Events/Events_InfoMessage.cpp @@ -25,18 +25,16 @@ void Events_InfoMessage::addParameter(double theParam) { - char aBuf[50]; - int n = sprintf(aBuf, "%g", theParam); - std::string aStr(aBuf); - myParameters.push_back(aStr); + static char aBuf[50]; + sprintf(aBuf, "%g", theParam); + myParameters.push_back(std::string(aBuf)); } void Events_InfoMessage::addParameter(int theParam) { - char aBuf[50]; - int n = sprintf(aBuf, "%d", theParam); - std::string aStr(aBuf); - myParameters.push_back(aStr); + static char aBuf[50]; + sprintf(aBuf, "%d", theParam); + myParameters.push_back(std::string(aBuf)); } void Events_InfoMessage::send() diff --git a/src/Events/Events_Loop.cpp b/src/Events/Events_Loop.cpp index 2723057a9..a51dba6a6 100644 --- a/src/Events/Events_Loop.cpp +++ b/src/Events/Events_Loop.cpp @@ -124,7 +124,7 @@ void Events_Loop::registerListener(Events_Listener* theListener, const Events_ID aFindID->second[theSender] = std::list(); aFindSender = aFindID->second.find(theSender); } - // check that listener was not registered wit hsuch parameters before + // check that listener was not registered with such parameters before std::list& aListeners = aFindSender->second; for (std::list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) if (*aL == theListener) @@ -156,14 +156,14 @@ void Events_Loop::removeListener(Events_Listener* theListener) aLMap.erase(aLIt->first); myListeners[anIt->first] = aLMap; if (aLMap.empty()) - break; // avoid incrementation of the iterator if the the container is empty + break; // avoid incrementation of the iterator if the container is empty } aLIt++; } if (anIt->second.empty()) { myListeners.erase(anIt->first); if (myListeners.empty()) - break; // avoid incrementation of the iterator if the the container is empty + break; // avoid incrementation of the iterator if the container is empty } anIt++; } @@ -174,7 +174,7 @@ void Events_Loop::removeListener(Events_Listener* theListener) if (anImIt->second == theListener) { myImmediateListeners.erase(anImIt->first); if (myImmediateListeners.empty()) - break; // avoid incrementation of the iterator if the the container is empty + break; // avoid incrementation of the iterator if the container is empty } anImIt++; } diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 688ffc03b..96d10441c 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -141,8 +141,6 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, aFormatName = "STEP"; } else if (anExtension == "IGES" || anExtension == "IGS") { aFormatName = "IGES-5.1"; - } else if (anExtension == "XAO") { - aFormatName = "XAO"; } else { aFormatName = anExtension; } @@ -167,12 +165,8 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, } // Store compound if we have more than one shape. - std::shared_ptr aShape; - if(aShapes.size() == 1) { - aShape = aShapes.front(); - } else { - aShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes); - } + std::shared_ptr aShape = + aShapes.size() == 1 ? aShapes.front() : GeomAlgoAPI_CompoundBuilder::compound(aShapes); // Perform the export std::string anError; @@ -535,18 +529,14 @@ bool ExchangePlugin_ExportFeature::isMacro() const return false; ExchangePlugin_ExportFeature* aThis = ((ExchangePlugin_ExportFeature*)(this)); AttributeStringPtr aFormatAttr = aThis->string(FILE_FORMAT_ID()); - if (!aFormatAttr.get()) - return false; - std::string aFormat = aFormatAttr->value(); + std::string aFormat(aFormatAttr.get() ? aFormatAttr->value() : ""); if (aFormat.empty()) { // get default format for the extension AttributeStringPtr aFilePathAttr = aThis->string(FILE_PATH_ID()); std::string aFilePath = aFilePathAttr->value(); if (!aFilePath.empty()) { std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath); - if (anExtension == "XAO") { - aFormat = "XAO"; - } + aFormat = anExtension; } } diff --git a/src/ModelAPI/ModelAPI_Result.cpp b/src/ModelAPI/ModelAPI_Result.cpp index 9e38ffb46..18c96fbc9 100644 --- a/src/ModelAPI/ModelAPI_Result.cpp +++ b/src/ModelAPI/ModelAPI_Result.cpp @@ -65,7 +65,7 @@ bool ModelAPI_Result::setDisabled(std::shared_ptr theThis, cons bool ModelAPI_Result::isDisabled() { - if (myIsDisabled != data()->isDeleted()) + if (data()->isValid() && myIsDisabled != data()->isDeleted()) setDisabled(std::dynamic_pointer_cast( data()->owner()), data()->isDeleted()); // restore from the data model the correct value return myIsDisabled; -- 2.39.2