forked from qt-creator/qt-creator
ModelEditor: Avoid corrupt diagrams after moving end of relation
Change-Id: If0a2a62d3ef7e59242b244d6892e83bb71315164 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user