Salome HOME
Issue #547 fix: not null data, even for the action features
authormpv <mpv@opencascade.com>
Wed, 27 May 2015 15:43:26 +0000 (18:43 +0300)
committermpv <mpv@opencascade.com>
Wed, 27 May 2015 15:43:26 +0000 (18:43 +0300)
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Objects.cpp
src/PartSet/PartSet_Module.cpp

index 2c973fa3f881e1c170c5fcd8db69860d42101d98..0fff37fd710476360669b9c7ed63058c9db8bdf0 100644 (file)
@@ -415,3 +415,8 @@ std::shared_ptr<ModelAPI_Data> Model_Data::invalidPtr()
 {
   return kInvalid;
 }
+
+std::shared_ptr<ModelAPI_Data> Model_Data::invalidData()
+{
+  return kInvalid;
+}
index cf90469ba46acfc003a3bf602e8e9ad96767c4aa..38733fb7209708d3b9a2147d3c00dd46821df3ac 100644 (file)
@@ -189,6 +189,9 @@ class Model_Data : public ModelAPI_Data
   /// Returns the invalid data pointer (to avoid working with NULL shared ptrs in swig)
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Data> invalidPtr();
 
+  /// Returns the invalid data pointer: static method
+  static std::shared_ptr<ModelAPI_Data> invalidData();
+
 protected:
   /// Returns true if "is in history" custom behaviors is defined for the feature
   MODEL_EXPORT virtual bool isInHistory();
index c53cdc23f10f997432b9437b914e2985b116c4aa..6bab4002bb9c3049dc51a0e44afffadb4413fe85 100644 (file)
@@ -126,6 +126,8 @@ void Model_Objects::addFeature(FeaturePtr theFeature, const FeaturePtr theAfterT
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent);
     theFeature->setDisabled(false); // by default created feature is enabled
     updateHistory(ModelAPI_Feature::group());
+  } else { // make feature has not-null data anyway
+    theFeature->setData(Model_Data::invalidData());
   }
 }
 
index 7f95d0893df73a2e20ac33addf08fbd7f9af74cd..563bd786c90403d2532382d3908b3091f512820a 100644 (file)
@@ -657,8 +657,6 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
     aOB->treeView()->setExpandsOnDoubleClick(false);
     connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), 
       SLOT(onTreeViewDoubleClick(const QModelIndex&)));
-    connect(aOB, SIGNAL(headerMouseDblClicked(const QModelIndex&)), 
-      SLOT(onTreeViewDoubleClick(const QModelIndex&)));
     connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), 
       myDataModel, SLOT(onMouseDoubleClick(const QModelIndex&)));
   }
@@ -758,14 +756,8 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
 
 void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
 {
-  SessionPtr aMgr = ModelAPI_Session::get();
-  if (!theIndex.isValid()) {
-    aMgr->setActiveDocument(aMgr->moduleDocument());
-    return;
-  }
   if (theIndex.column() != 0) // Use only first column
     return;
-
   ObjectPtr aObj = myDataModel->object(theIndex);
   ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
   if (!aPart.get()) { // Probably this is Feature
@@ -775,7 +767,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
     }
   }
   if (aPart.get()) { // if this is a part
-    
+    SessionPtr aMgr = ModelAPI_Session::get();
     if (aPart->partDoc() == aMgr->activeDocument()) {
       aMgr->setActiveDocument(aMgr->moduleDocument());
     } else {