Salome HOME
projects
/
modules
/
shaper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Issue #459: Check pre-selection for group operation
[modules/shaper.git]
/
src
/
Model
/
Model_Document.cpp
diff --git
a/src/Model/Model_Document.cpp
b/src/Model/Model_Document.cpp
index 00531ba8445b1ff25404cbee87f8ca7c3cf03ad5..ec0c236f6f0389ab60177023a65ab8e30a399696 100644
(file)
--- a/
src/Model/Model_Document.cpp
+++ b/
src/Model/Model_Document.cpp
@@
-557,13
+557,18
@@
FeaturePtr Model_Document::addFeature(std::string theID)
{
TDF_Label anEmptyLab;
FeaturePtr anEmptyFeature;
{
TDF_Label anEmptyLab;
FeaturePtr anEmptyFeature;
- FeaturePtr aFeature =
- std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get())->createFeature(theID, this);
+ std::shared_ptr<Model_Session> aSession =
+ std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get());
+ FeaturePtr aFeature = aSession->createFeature(theID, this);
if (!aFeature)
return aFeature;
Model_Document* aDocToAdd;
if (!aFeature)
return aFeature;
Model_Document* aDocToAdd;
- if (aFeature->documentToAdd().get()) { // use the customized document to add
- aDocToAdd = std::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd()).get();
+ if (!aFeature->documentToAdd().empty()) { // use the customized document to add
+ if (aFeature->documentToAdd() != kind()) { // the root document by default
+ aDocToAdd = std::dynamic_pointer_cast<Model_Document>(aSession->moduleDocument()).get();
+ } else {
+ aDocToAdd = this;
+ }
} else { // if customized is not presented, add to "this" document
aDocToAdd = this;
}
} else { // if customized is not presented, add to "this" document
aDocToAdd = this;
}