summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Clever <clushkou@gmx.net>2016-11-18 22:36:10 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-11-26 22:07:35 (GMT)
commitc7250ebcb0886f47f4e694a6b4d2ea369adc0a89 (patch)
tree5ee8c137a5f0f002806514297cb23585905daf6b
parent052e0223d7501e25fe09f3721ed28583e23b4087 (diff)
Restrict write access to UMLScene::widgetList to track NULL-pointer list entries.
CCBUG:371990
-rw-r--r--umbrello/clipboard/umlclipboard.cpp2
-rw-r--r--umbrello/clipboard/umlclipboard.h2
-rw-r--r--umbrello/cmds/widget/cmdbasewidgetcommand.cpp2
-rw-r--r--umbrello/codeimport/import_utils.cpp4
-rw-r--r--umbrello/toolbarstatemessages.cpp2
-rw-r--r--umbrello/umlscene.cpp18
-rw-r--r--umbrello/umlscene.h5
-rw-r--r--umbrello/umlwidgets/combinedfragmentwidget.cpp4
8 files changed, 24 insertions, 15 deletions
diff --git a/umbrello/clipboard/umlclipboard.cpp b/umbrello/clipboard/umlclipboard.cpp
index f42da57..725d9a7 100644
--- a/umbrello/clipboard/umlclipboard.cpp
+++ b/umbrello/clipboard/umlclipboard.cpp
@@ -267,7 +267,7 @@ void UMLClipboard::addRelatedWidgets()
*
* @param UMLWidgetList& widgets
*/
-void UMLClipboard::fillObjectListForWidgets(UMLWidgetList& widgets)
+void UMLClipboard::fillObjectListForWidgets(const UMLWidgetList& widgets)
{
// The order of the packages in the clip matters. So we collect
// the packages and add them from the root package to the deeper levels
diff --git a/umbrello/clipboard/umlclipboard.h b/umbrello/clipboard/umlclipboard.h
index b67d6ab..3b50655 100644
--- a/umbrello/clipboard/umlclipboard.h
+++ b/umbrello/clipboard/umlclipboard.h
@@ -70,7 +70,7 @@ private:
private:
void addRelatedWidgets();
- void fillObjectListForWidgets(UMLWidgetList& widgets);
+ void fillObjectListForWidgets(const UMLWidgetList& widgets);
bool fillSelectionLists(UMLListViewItemList& selectedItems);
diff --git a/umbrello/cmds/widget/cmdbasewidgetcommand.cpp b/umbrello/cmds/widget/cmdbasewidgetcommand.cpp
index 86a379a..c260fd1 100644
--- a/umbrello/cmds/widget/cmdbasewidgetcommand.cpp
+++ b/umbrello/cmds/widget/cmdbasewidgetcommand.cpp
@@ -74,7 +74,7 @@ namespace Uml
if (umlWidget->isMessageWidget()) {
scene()->messageList().append(umlWidget->asMessageWidget());
} else {
- scene()->widgetList().append(umlWidget);
+ scene()->addWidget(umlWidget);
}
umlWidget->activate();
diff --git a/umbrello/codeimport/import_utils.cpp b/umbrello/codeimport/import_utils.cpp
index 1871be6..f513d0a 100644
--- a/umbrello/codeimport/import_utils.cpp
+++ b/umbrello/codeimport/import_utils.cpp
@@ -782,7 +782,7 @@ bool importStackTrace(const QString &fileName, UMLScene *scene)
ObjectWidget *leftWidget = (ObjectWidget *)Widget_Factory::createWidget(scene, left);
leftWidget->activate();
// required to be savable
- scene->widgetList().append(leftWidget);
+ scene->addWidget(leftWidget);
objectsMap[name] = leftWidget;
ObjectWidget *rightWidget = 0;
@@ -821,7 +821,7 @@ bool importStackTrace(const QString &fileName, UMLScene *scene)
rightWidget->setX(mostRightWidget->x() + mostRightWidget->width() + 10);
rightWidget->activate();
objectsMap[package] = rightWidget;
- scene->widgetList().append(rightWidget);
+ scene->addWidget(rightWidget);
mostRightWidget = rightWidget;
}
diff --git a/umbrello/toolbarstatemessages.cpp b/umbrello/toolbarstatemessages.cpp
index a3aac17..13774dc 100644
--- a/umbrello/toolbarstatemessages.cpp
+++ b/umbrello/toolbarstatemessages.cpp
@@ -313,7 +313,7 @@ void ToolBarStateMessages::setupMessageWidget(MessageWidget *message)
//Shouldn't it cancel also the whole creation?
ft->showOperationDialog();
message->setTextPosition();
- m_pUMLScene->widgetList().append(ft);
+ m_pUMLScene->addWidget(ft);
UMLApp::app()->document()->setModified();
}
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index e955b98..c3982ec 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -461,11 +461,17 @@ AssociationWidgetList& UMLScene::associationList()
/**
* Returns a reference to the widget list.
*/
-UMLWidgetList& UMLScene::widgetList()
+const UMLWidgetList& UMLScene::widgetList() const
{
return m_WidgetList;
}
+void UMLScene::addWidget(UMLWidget* widget)
+{
+ Q_ASSERT(0 != widget);
+ m_WidgetList.append(widget);
+}
+
/**
* Returns a reference to the message list.
*/
@@ -572,7 +578,7 @@ void UMLScene::setupNewWidget(UMLWidget *w, bool setPosition)
m_doc->setModified();
if (m_doc->loading()) { // do not emit signals while loading
- m_WidgetList.append(w);
+ addWidget(w);
// w->activate(); // will be done by UMLDoc::activateAllViews() after loading
} else {
UMLApp::app()->executeCommand(new CmdCreateWidget(w));
@@ -1901,7 +1907,7 @@ void UMLScene::addFloatingTextWidget(FloatingTextWidget* pWidget)
}
}
- m_WidgetList.append(pWidget);
+ addWidget(pWidget);
}
/**
@@ -3735,7 +3741,7 @@ bool UMLScene::loadWidgetsFromXMI(QDomElement & qElement)
while (!widgetElement.isNull()) {
widget = loadWidgetFromXMI(widgetElement);
if (widget) {
- m_WidgetList.append(widget);
+ addWidget(widget);
widget->clipSize();
// In the interest of best-effort loading, in case of a
// (widget == 0) we still go on.
@@ -3793,7 +3799,7 @@ bool UMLScene::loadMessagesFromXMI(QDomElement & qElement)
m_MessageList.append(message);
FloatingTextWidget *ft = message->floatingTextWidget();
if (ft)
- m_WidgetList.append(ft);
+ addWidget(ft);
else if (message->sequenceMessageType() != SequenceMessage::Creation)
DEBUG(DBG_SRC) << "floating text is NULL for message " << Uml::ID::toString(message->id());
}
@@ -3937,7 +3943,7 @@ bool UMLScene::loadUisDiagramPresentation(QDomElement & qElement)
widget->setX(x);
widget->setY(y);
widget->setSize(w, h);
- m_WidgetList.append(widget);
+ addWidget(widget);
}
}
}
diff --git a/umbrello/umlscene.h b/umbrello/umlscene.h
index 1bd37f3..09cc128 100644
--- a/umbrello/umlscene.h
+++ b/umbrello/umlscene.h
@@ -149,7 +149,8 @@ public:
void setOptionState(const Settings::OptionState& options);
AssociationWidgetList& associationList();
- UMLWidgetList& widgetList();
+ const UMLWidgetList& widgetList() const;
+ void addWidget(UMLWidget* widget);
MessageWidgetList& messageList();
bool isOpen() const;
@@ -327,7 +328,9 @@ protected:
Settings::OptionState m_Options; ///< Options used by view.
MessageWidgetList m_MessageList; ///< All the message widgets on the diagram.
+private:
UMLWidgetList m_WidgetList; ///< All the UMLWidgets on the diagram.
+protected:
AssociationWidgetList m_AssociationList; ///< All the AssociationWidgets on the diagram.
bool m_bUseSnapToGrid; ///< Flag to use snap to grid. The default is off.
diff --git a/umbrello/umlwidgets/combinedfragmentwidget.cpp b/umbrello/umlwidgets/combinedfragmentwidget.cpp
index 283532d..a11343a 100644
--- a/umbrello/umlwidgets/combinedfragmentwidget.cpp
+++ b/umbrello/umlwidgets/combinedfragmentwidget.cpp
@@ -236,7 +236,7 @@ void CombinedFragmentWidget::setCombinedFragmentType(CombinedFragmentType combin
m_dashLines.back()->setYMax(y() + height());
m_dashLines.back()->setY(y() + height()/2);
m_dashLines.back()->setSize(width(), m_dashLines.back()->height());
- m_scene->widgetList().append(m_dashLines.back());
+ m_scene->addWidget(m_dashLines.back());
}
}
@@ -368,7 +368,7 @@ bool CombinedFragmentWidget::loadFromXMI(QDomElement & qElement)
return false;
}
else {
- m_scene->widgetList().append(fdlwidget);
+ m_scene->addWidget(fdlwidget);
fdlwidget->clipSize();
}
} else {