+ fix overflow problem with string buffer in fuse and common command
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5391 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <QString>
|
||||
# include <QDir>
|
||||
# include <QFileInfo>
|
||||
@@ -295,17 +296,18 @@ void CmdPartCommon::activated(int iMsg)
|
||||
std::string FeatName = getUniqueObjectName("Common");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::string ObjectBuf;
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Shapes = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
ObjectBuf += std::string("App.activeDocument().") + it->FeatName + ",";
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
}
|
||||
ObjectBuf.erase(--ObjectBuf.end());
|
||||
str << "]";
|
||||
|
||||
openCommand("Common");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiCommon\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Shapes = [%s]",FeatName.c_str(),ObjectBuf.c_str());
|
||||
runCommand(Doc,str.str().c_str());
|
||||
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
|
||||
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", tempSelNames.front().c_str());
|
||||
@@ -348,17 +350,18 @@ void CmdPartFuse::activated(int iMsg)
|
||||
std::string FeatName = getUniqueObjectName("Fusion");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::string ObjectBuf;
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Shapes = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
ObjectBuf += std::string("App.activeDocument().") + it->FeatName + ",";
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
}
|
||||
ObjectBuf.erase(--ObjectBuf.end());
|
||||
str << "]";
|
||||
|
||||
openCommand("Fusion");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiFuse\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Shapes = [%s]",FeatName.c_str(),ObjectBuf.c_str());
|
||||
runCommand(Doc,str.str().c_str());
|
||||
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
|
||||
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", tempSelNames.front().c_str());
|
||||
|
||||
Reference in New Issue
Block a user