Commit 1bb11c5b authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Avoid corrupt diagrams after moving end of relation

Change-Id: If0a2a62d3ef7e59242b244d6892e83bb71315164
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent 222f8947
......@@ -87,6 +87,7 @@ public:
void setModelController(ModelController *modelController);
UndoController *undoController() const { return m_undoController; }
void setUndoController(UndoController *undoController);
QList<MDiagram *> allDiagrams() const { return m_allDiagrams; }
private:
MDiagram *findDiagram(const Uid &diagramKey) const;
......
......@@ -724,8 +724,18 @@ bool DiagramSceneController::relocateRelationEnd(DRelation *relation, DObject *t
MObject *currentTargetMObject = m_modelController->findObject((modelRelation->*endUid)());
QMT_CHECK(currentTargetMObject);
m_modelController->undoController()->beginMergeSequence(tr("Relocate Relation"));
// move relation into new target if it was a child of the old target
if (currentTargetMObject == modelRelation->owner())
m_modelController->moveRelation(targetMObject, modelRelation);
// remove relation on all diagrams where the new targe element does not exist
foreach (MDiagram *diagram, m_diagramController->allDiagrams()) {
if (DElement *diagramRelation = m_diagramController->findDelegate(modelRelation, diagram)) {
if (!m_diagramController->findDelegate(targetMObject, diagram)) {
m_diagramController->removeElement(diagramRelation, diagram);
}
}
}
// update end of relation
m_modelController->startUpdateRelation(modelRelation);
(modelRelation->*setEndUid)(targetMObject->uid());
m_modelController->finishUpdateRelation(modelRelation, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment