浏览代码

Delegates memory management of all steps to ctkWorkflow

* Before that change, the deletion of steps was a process shared
between ctkWorkflowWidget and ctkWorkflow. Following that change,
ctkWorkflowWidget delegates that task to ctkWorkflow making sure that
the ctkWorkflowWidgetStep have no parent.

* The "isWidgetType" method previously introduced (3b1b1d3162) is maintain
has convenience method.

* Centralizing the deletion of steps also makes the "cleaning" of memory
easier and less intricated from the perspective of python/pythonqt.

* For reference, it may be useful to look at 3b1b1d3162, bd742afbd00 and f0609f790
Jean-Christophe Fillion-Robin 13 年之前
父节点
当前提交
fa62c67cc7
共有 2 个文件被更改,包括 13 次插入6 次删除
  1. 1 6
      Libs/Core/ctkWorkflow.cpp
  2. 12 0
      Libs/Widgets/ctkWorkflowWidget.cpp

+ 1 - 6
Libs/Core/ctkWorkflow.cpp

@@ -562,12 +562,7 @@ ctkWorkflow::~ctkWorkflow()
   // Clean registered step
   while (!d->RegisteredSteps.isEmpty())
     {
-    ctkWorkflowStep * step = d->RegisteredSteps.takeFirst();
-    if (!step->isWidgetType())
-      {
-      delete step;
-      }
-
+    delete d->RegisteredSteps.takeFirst();
     }
 }
 

+ 12 - 0
Libs/Widgets/ctkWorkflowWidget.cpp

@@ -70,6 +70,18 @@ ctkWorkflowWidgetPrivate::ctkWorkflowWidgetPrivate()
 //---------------------------------------------------------------------------
 ctkWorkflowWidgetPrivate::~ctkWorkflowWidgetPrivate()
 {
+  if (this->Workflow)
+    {
+    foreach(ctkWorkflowStep* step, this->Workflow->steps())
+      {
+      ctkWorkflowWidgetStep * widgetStep = dynamic_cast<ctkWorkflowWidgetStep*>(step);
+      if (widgetStep)
+        {
+        widgetStep->setVisible(false);
+        widgetStep->setParent(0);
+        }
+      }
+    }
 }
 
 // --------------------------------------------------------------------------