]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Improve the coverage level.
authormpv <mpv@opencascade.com>
Thu, 30 May 2019 12:28:28 +0000 (15:28 +0300)
committermpv <mpv@opencascade.com>
Thu, 30 May 2019 12:28:28 +0000 (15:28 +0300)
src/Events/Events_InfoMessage.cpp
src/Events/Events_Loop.cpp
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ModelAPI/ModelAPI_Result.cpp

index f85bed86846604220216215418037208024dbb98..a9b3cd3fbcfe5617a59b4060ef8611b669876cb1 100644 (file)
 
 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()
index 2723057a964a43bd7ba065c24fada25add300ecc..a51dba6a63bf89c2b479abeb8ff1b576e84c7580 100644 (file)
@@ -124,7 +124,7 @@ void Events_Loop::registerListener(Events_Listener* theListener, const Events_ID
     aFindID->second[theSender] = std::list<Events_Listener*>();
     aFindSender = aFindID->second.find(theSender);
   }
-  // check that listener was not registered wit hsuch parameters before
+  // check that listener was not registered witsuch parameters before
   std::list<Events_Listener*>& aListeners = aFindSender->second;
   for (std::list<Events_Listener*>::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++;
   }
index 688ffc03b289b9903822431dba9871bcc3c1ea33..96d10441c6698de60bf23cea44debbce7186261f 100644 (file)
@@ -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<GeomAPI_Shape> aShape;
-  if(aShapes.size() == 1) {
-    aShape = aShapes.front();
-  } else {
-    aShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
-  }
+  std::shared_ptr<GeomAPI_Shape> 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;
     }
   }
 
index 9e38ffb46a4894d5498fd17a3e17843bc0d27652..18c96fbc91edff5665d7319f270921dd2fb66244 100644 (file)
@@ -65,7 +65,7 @@ bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, cons
 
 bool ModelAPI_Result::isDisabled()
 {
-  if (myIsDisabled != data()->isDeleted())
+  if (data()->isValid() && myIsDisabled != data()->isDeleted())
     setDisabled(std::dynamic_pointer_cast<ModelAPI_Result>(
       data()->owner()), data()->isDeleted()); // restore from the data model the correct value
   return myIsDisabled;