ModelEditor: Introduce QMT_ASSERT

This change shall solve a lot of Coverity findings

Change-Id: I1e699f7363426e9b6008fc77d3f498fe3d968b4f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Jochen Becher
2017-07-09 11:49:13 +02:00
parent 8ccdbe1944
commit 05f7b92f0a
49 changed files with 360 additions and 362 deletions

View File

@@ -57,10 +57,10 @@ void StringTextSource::setSourceId(int sourceId)
SourceChar StringTextSource::readNextChar() SourceChar StringTextSource::readNextChar()
{ {
QMT_CHECK(m_sourceId >= 0); QMT_ASSERT(m_sourceId >= 0, return SourceChar());
QMT_CHECK(m_index >= 0); QMT_ASSERT(m_index >= 0, return SourceChar());
QMT_CHECK(m_lineNumber >= 0); QMT_ASSERT(m_lineNumber >= 0, return SourceChar());
QMT_CHECK(m_columnNumber >= 0); QMT_ASSERT(m_columnNumber >= 0, return SourceChar());
if (m_index >= m_text.length()) if (m_index >= m_text.length())
return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber)); return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber));

View File

@@ -66,7 +66,7 @@ void DFactory::visitMElement(const MElement *element)
void DFactory::visitMObject(const MObject *object) void DFactory::visitMObject(const MObject *object)
{ {
auto diagramObject = dynamic_cast<DObject *>(m_product); auto diagramObject = dynamic_cast<DObject *>(m_product);
QMT_CHECK(diagramObject); QMT_ASSERT(diagramObject, return);
diagramObject->setModelUid(object->uid()); diagramObject->setModelUid(object->uid());
visitMElement(object); visitMElement(object);
} }
@@ -120,7 +120,7 @@ void DFactory::visitMItem(const MItem *item)
void DFactory::visitMRelation(const MRelation *relation) void DFactory::visitMRelation(const MRelation *relation)
{ {
auto diagramRelation = dynamic_cast<DRelation *>(m_product); auto diagramRelation = dynamic_cast<DRelation *>(m_product);
QMT_CHECK(diagramRelation); QMT_ASSERT(diagramRelation, return);
diagramRelation->setModelUid(relation->uid()); diagramRelation->setModelUid(relation->uid());
visitMElement(relation); visitMElement(relation);
} }

View File

@@ -59,7 +59,7 @@ void DFlatAssignmentVisitor::visitDObject(const DObject *object)
{ {
visitDElement(object); visitDElement(object);
auto target = dynamic_cast<DObject *>(m_target); auto target = dynamic_cast<DObject *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setStereotypes(object->stereotypes()); target->setStereotypes(object->stereotypes());
target->setName(object->name()); target->setName(object->name());
target->setPos(object->pos()); target->setPos(object->pos());
@@ -81,7 +81,7 @@ void DFlatAssignmentVisitor::visitDClass(const DClass *klass)
{ {
visitDObject(klass); visitDObject(klass);
auto target = dynamic_cast<DClass *>(m_target); auto target = dynamic_cast<DClass *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setUmlNamespace(klass->umlNamespace()); target->setUmlNamespace(klass->umlNamespace());
target->setTemplateParameters(klass->templateParameters()); target->setTemplateParameters(klass->templateParameters());
target->setTemplateDisplay(klass->templateDisplay()); target->setTemplateDisplay(klass->templateDisplay());
@@ -94,7 +94,7 @@ void DFlatAssignmentVisitor::visitDComponent(const DComponent *component)
{ {
visitDObject(component); visitDObject(component);
auto target = dynamic_cast<DComponent *>(m_target); auto target = dynamic_cast<DComponent *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setPlainShape(component->isPlainShape()); target->setPlainShape(component->isPlainShape());
} }
@@ -107,7 +107,7 @@ void DFlatAssignmentVisitor::visitDItem(const DItem *item)
{ {
visitDObject(item); visitDObject(item);
auto target = dynamic_cast<DItem *>(m_target); auto target = dynamic_cast<DItem *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setVariety(target->variety()); target->setVariety(target->variety());
target->setShapeEditable(target->isShapeEditable()); target->setShapeEditable(target->isShapeEditable());
target->setShape(target->shape()); target->setShape(target->shape());
@@ -117,7 +117,7 @@ void DFlatAssignmentVisitor::visitDRelation(const DRelation *relation)
{ {
visitDElement(relation); visitDElement(relation);
auto target = dynamic_cast<DRelation *>(m_target); auto target = dynamic_cast<DRelation *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setStereotypes(relation->stereotypes()); target->setStereotypes(relation->stereotypes());
target->setIntermediatePoints(relation->intermediatePoints()); target->setIntermediatePoints(relation->intermediatePoints());
} }
@@ -131,7 +131,7 @@ void DFlatAssignmentVisitor::visitDDependency(const DDependency *dependency)
{ {
visitDRelation(dependency); visitDRelation(dependency);
auto target = dynamic_cast<DDependency *>(m_target); auto target = dynamic_cast<DDependency *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setDirection(dependency->direction()); target->setDirection(dependency->direction());
} }
@@ -139,7 +139,7 @@ void DFlatAssignmentVisitor::visitDAssociation(const DAssociation *association)
{ {
visitDRelation(association); visitDRelation(association);
auto target = dynamic_cast<DAssociation *>(m_target); auto target = dynamic_cast<DAssociation *>(m_target);
QMT_CHECK(target); QMT_ASSERT(target, return);
target->setEndA(association->endA()); target->setEndA(association->endA());
target->setEndB(association->endB()); target->setEndB(association->endB());
} }

View File

@@ -151,7 +151,7 @@ private:
MDiagram *diagram = this->diagram(); MDiagram *diagram = this->diagram();
foreach (DElement *clonedElement, m_clonedElements) { foreach (DElement *clonedElement, m_clonedElements) {
DElement *activeElement = diagramController->findElement(clonedElement->uid(), diagram); DElement *activeElement = diagramController->findElement(clonedElement->uid(), diagram);
QMT_CHECK(activeElement); QMT_ASSERT(activeElement, return);
int row = diagram->diagramElements().indexOf(activeElement); int row = diagram->diagramElements().indexOf(activeElement);
emit diagramController->beginUpdateElement(row, diagram); emit diagramController->beginUpdateElement(row, diagram);
// clone active element // clone active element
@@ -198,9 +198,9 @@ protected:
Clone &clone = m_clonedElements[i]; Clone &clone = m_clonedElements[i];
QMT_CHECK(!clone.m_clonedElement); QMT_CHECK(!clone.m_clonedElement);
DElement *activeElement = diagramController->findElement(clone.m_elementKey, diagram); DElement *activeElement = diagramController->findElement(clone.m_elementKey, diagram);
QMT_CHECK(activeElement); QMT_ASSERT(activeElement, return);
clone.m_indexOfElement = diagram->diagramElements().indexOf(activeElement); clone.m_indexOfElement = diagram->diagramElements().indexOf(activeElement);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_ASSERT(clone.m_indexOfElement >= 0, return);
emit diagramController->beginRemoveElement(clone.m_indexOfElement, diagram); emit diagramController->beginRemoveElement(clone.m_indexOfElement, diagram);
DCloneDeepVisitor cloneVisitor; DCloneDeepVisitor cloneVisitor;
activeElement->accept(&cloneVisitor); activeElement->accept(&cloneVisitor);
@@ -221,7 +221,7 @@ protected:
bool inserted = false; bool inserted = false;
for (int i = m_clonedElements.count() - 1; i >= 0; --i) { for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
Clone &clone = m_clonedElements[i]; Clone &clone = m_clonedElements[i];
QMT_CHECK(clone.m_clonedElement); QMT_ASSERT(clone.m_clonedElement, return);
QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey); QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey);
emit diagramController->beginInsertElement(clone.m_indexOfElement, diagram); emit diagramController->beginInsertElement(clone.m_indexOfElement, diagram);
diagram->insertDiagramElement(clone.m_indexOfElement, clone.m_clonedElement); diagram->insertDiagramElement(clone.m_indexOfElement, clone.m_clonedElement);
@@ -287,7 +287,7 @@ public:
DCloneDeepVisitor visitor; DCloneDeepVisitor visitor;
element->accept(&visitor); element->accept(&visitor);
clone.m_clonedElement = visitor.cloned(); clone.m_clonedElement = visitor.cloned();
QMT_CHECK(clone.m_clonedElement); QMT_ASSERT(clone.m_clonedElement, return);
m_clonedElements.append(clone); m_clonedElements.append(clone);
} }
@@ -424,7 +424,7 @@ void DiagramController::removeElement(DElement *element, MDiagram *diagram)
DElement *DiagramController::findElement(const Uid &key, const MDiagram *diagram) const DElement *DiagramController::findElement(const Uid &key, const MDiagram *diagram) const
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return nullptr);
return diagram->findDiagramElement(key); return diagram->findDiagramElement(key);
} }
@@ -476,7 +476,7 @@ DContainer DiagramController::cutElements(const DSelection &diagramSelection, MD
DContainer DiagramController::copyElements(const DSelection &diagramSelection, const MDiagram *diagram) DContainer DiagramController::copyElements(const DSelection &diagramSelection, const MDiagram *diagram)
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return DContainer());
DReferences simplifiedSelection = simplify(diagramSelection, diagram); DReferences simplifiedSelection = simplify(diagramSelection, diagram);
DContainer copiedElements; DContainer copiedElements;
@@ -491,7 +491,7 @@ DContainer DiagramController::copyElements(const DSelection &diagramSelection, c
void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagram *diagram) void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagram *diagram)
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
// clone all elements and renew their keys // clone all elements and renew their keys
QHash<Uid, Uid> renewedKeys; QHash<Uid, Uid> renewedKeys;
@@ -593,7 +593,7 @@ void DiagramController::onBeginUpdateObject(int row, const MObject *parent)
void DiagramController::onEndUpdateObject(int row, const MObject *parent) void DiagramController::onEndUpdateObject(int row, const MObject *parent)
{ {
MObject *modelObject = m_modelController->object(row, parent); MObject *modelObject = m_modelController->object(row, parent);
QMT_CHECK(modelObject); QMT_ASSERT(modelObject, return);
auto modelPackage = dynamic_cast<MPackage *>(modelObject); auto modelPackage = dynamic_cast<MPackage *>(modelObject);
foreach (MDiagram *diagram, m_allDiagrams) { foreach (MDiagram *diagram, m_allDiagrams) {
DObject *object = findDelegate<DObject>(modelObject, diagram); DObject *object = findDelegate<DObject>(modelObject, diagram);
@@ -622,7 +622,7 @@ void DiagramController::onBeginInsertObject(int row, const MObject *owner)
void DiagramController::onEndInsertObject(int row, const MObject *owner) void DiagramController::onEndInsertObject(int row, const MObject *owner)
{ {
QMT_CHECK(owner); QMT_ASSERT(owner, return);
MObject *modelObject = m_modelController->object(row, owner); MObject *modelObject = m_modelController->object(row, owner);
if (auto modelDiagram = dynamic_cast<MDiagram *>(modelObject)) { if (auto modelDiagram = dynamic_cast<MDiagram *>(modelObject)) {
@@ -634,7 +634,7 @@ void DiagramController::onEndInsertObject(int row, const MObject *owner)
void DiagramController::onBeginRemoveObject(int row, const MObject *parent) void DiagramController::onBeginRemoveObject(int row, const MObject *parent)
{ {
QMT_CHECK(parent); QMT_ASSERT(parent, return);
MObject *modelObject = m_modelController->object(row, parent); MObject *modelObject = m_modelController->object(row, parent);
removeObjects(modelObject); removeObjects(modelObject);
@@ -658,7 +658,7 @@ void DiagramController::onEndMoveObject(int row, const MObject *owner)
// if diagram was moved update all elements because of changed context // if diagram was moved update all elements because of changed context
MObject *modelObject = m_modelController->object(row, owner); MObject *modelObject = m_modelController->object(row, owner);
QMT_CHECK(modelObject); QMT_ASSERT(modelObject, return);
auto modelDiagram = dynamic_cast<MDiagram *>(modelObject); auto modelDiagram = dynamic_cast<MDiagram *>(modelObject);
if (modelDiagram) { if (modelDiagram) {
emit beginResetDiagram(modelDiagram); emit beginResetDiagram(modelDiagram);
@@ -691,7 +691,7 @@ void DiagramController::onEndUpdateRelation(int row, const MObject *owner)
void DiagramController::onBeginRemoveRelation(int row, const MObject *owner) void DiagramController::onBeginRemoveRelation(int row, const MObject *owner)
{ {
QMT_CHECK(owner); QMT_ASSERT(owner, return);
MRelation *modelRelation = owner->relations().at(row); MRelation *modelRelation = owner->relations().at(row);
removeRelations(modelRelation); removeRelations(modelRelation);
@@ -719,7 +719,7 @@ void DiagramController::onEndMoveRelation(int row, const MObject *owner)
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram, void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram,
const QString &commandLabel) const QString &commandLabel)
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
DReferences simplifiedSelection = simplify(diagramSelection, diagram); DReferences simplifiedSelection = simplify(diagramSelection, diagram);
if (simplifiedSelection.elements().isEmpty()) if (simplifiedSelection.elements().isEmpty())
@@ -818,7 +818,7 @@ void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys) void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys)
{ {
QMT_CHECK(renewedKeys); QMT_ASSERT(renewedKeys, return);
if (element) { if (element) {
DElement *existingElementOnDiagram = findElementOnAnyDiagram(element->uid()); DElement *existingElementOnDiagram = findElementOnAnyDiagram(element->uid());
@@ -850,7 +850,7 @@ void DiagramController::updateElementFromModel(DElement *element, const MDiagram
DUpdateVisitor visitor(element, diagram); DUpdateVisitor visitor(element, diagram);
MElement *melement = m_modelController->findElement(element->modelUid()); MElement *melement = m_modelController->findElement(element->modelUid());
QMT_CHECK(melement); QMT_ASSERT(melement, return);
if (emitUpdateSignal) { if (emitUpdateSignal) {
visitor.setCheckNeedsUpdate(true); visitor.setCheckNeedsUpdate(true);
@@ -925,7 +925,7 @@ void DiagramController::verifyDiagramsIntegrity()
FindDiagramsVisitor visitor(&allDiagrams); FindDiagramsVisitor visitor(&allDiagrams);
m_modelController->rootPackage()->accept(&visitor); m_modelController->rootPackage()->accept(&visitor);
} }
QMT_CHECK(allDiagrams == m_allDiagrams); QMT_ASSERT(allDiagrams == m_allDiagrams, return);
foreach (const MDiagram *diagram, allDiagrams) foreach (const MDiagram *diagram, allDiagrams)
verifyDiagramIntegrity(diagram); verifyDiagramIntegrity(diagram);
} }
@@ -937,8 +937,8 @@ void DiagramController::verifyDiagramIntegrity(const MDiagram *diagram)
foreach (const DElement *delement, diagram->diagramElements()) { foreach (const DElement *delement, diagram->diagramElements()) {
delementsMap.insert(delement->uid(), delement); delementsMap.insert(delement->uid(), delement);
if (dynamic_cast<const DObject *>(delement) != 0 || dynamic_cast<const DRelation *>(delement) != 0) { if (dynamic_cast<const DObject *>(delement) != 0 || dynamic_cast<const DRelation *>(delement) != 0) {
QMT_CHECK(delement->modelUid().isValid()); QMT_ASSERT(delement->modelUid().isValid(), return);
QMT_CHECK(m_modelController->findElement(delement->modelUid()) != 0); QMT_ASSERT(m_modelController->findElement(delement->modelUid()) != 0, return);
if (!delement->modelUid().isValid() || m_modelController->findElement(delement->modelUid()) == 0) { if (!delement->modelUid().isValid() || m_modelController->findElement(delement->modelUid()) == 0) {
if (const DObject *dobject = dynamic_cast<const DObject *>(delement)) if (const DObject *dobject = dynamic_cast<const DObject *>(delement))
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": object" << dobject->name() << dobject->uid().toString() << "has invalid reference to model element."; qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": object" << dobject->name() << dobject->uid().toString() << "has invalid reference to model element.";
@@ -946,17 +946,17 @@ void DiagramController::verifyDiagramIntegrity(const MDiagram *diagram)
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid refeference to model element."; qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid refeference to model element.";
} }
} else { } else {
QMT_CHECK(!delement->modelUid().isValid()); QMT_ASSERT(!delement->modelUid().isValid(), return);
} }
} }
foreach (const DElement *delement, diagram->diagramElements()) { foreach (const DElement *delement, diagram->diagramElements()) {
if (const DRelation *drelation = dynamic_cast<const DRelation *>(delement)) { if (const DRelation *drelation = dynamic_cast<const DRelation *>(delement)) {
QMT_CHECK(drelation->endAUid().isValid()); QMT_ASSERT(drelation->endAUid().isValid(), return);
QMT_CHECK(delementsMap.contains(drelation->endAUid())); QMT_ASSERT(delementsMap.contains(drelation->endAUid()), return);
if (!drelation->endAUid().isValid() || !delementsMap.contains(drelation->endAUid())) if (!drelation->endAUid().isValid() || !delementsMap.contains(drelation->endAUid()))
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end A."; qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end A.";
QMT_CHECK(drelation->endBUid().isValid()); QMT_ASSERT(drelation->endBUid().isValid(), return);
QMT_CHECK(delementsMap.contains(drelation->endBUid())); QMT_ASSERT(delementsMap.contains(drelation->endBUid()), return);
if (!drelation->endBUid().isValid() || !delementsMap.contains(drelation->endBUid())) if (!drelation->endBUid().isValid() || !delementsMap.contains(drelation->endBUid()))
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end B."; qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end B.";
} }

View File

@@ -72,7 +72,7 @@ void DUpdateVisitor::visitMElement(const MElement *element)
void DUpdateVisitor::visitMObject(const MObject *object) void DUpdateVisitor::visitMObject(const MObject *object)
{ {
auto dobject = dynamic_cast<DObject *>(m_target); auto dobject = dynamic_cast<DObject *>(m_target);
QMT_CHECK(dobject); QMT_ASSERT(dobject, return);
if (isUpdating(object->stereotypes() != dobject->stereotypes())) if (isUpdating(object->stereotypes() != dobject->stereotypes()))
dobject->setStereotypes(object->stereotypes()); dobject->setStereotypes(object->stereotypes());
const MObject *objectOwner = object->owner(); const MObject *objectOwner = object->owner();
@@ -107,7 +107,7 @@ void DUpdateVisitor::visitMPackage(const MPackage *package)
void DUpdateVisitor::visitMClass(const MClass *klass) void DUpdateVisitor::visitMClass(const MClass *klass)
{ {
auto dclass = dynamic_cast<DClass *>(m_target); auto dclass = dynamic_cast<DClass *>(m_target);
QMT_CHECK(dclass); QMT_ASSERT(dclass, return);
if (isUpdating(klass->umlNamespace() != dclass->umlNamespace())) if (isUpdating(klass->umlNamespace() != dclass->umlNamespace()))
dclass->setUmlNamespace(klass->umlNamespace()); dclass->setUmlNamespace(klass->umlNamespace());
if (isUpdating(klass->templateParameters() != dclass->templateParameters())) if (isUpdating(klass->templateParameters() != dclass->templateParameters()))
@@ -135,7 +135,7 @@ void DUpdateVisitor::visitMCanvasDiagram(const MCanvasDiagram *diagram)
void DUpdateVisitor::visitMItem(const MItem *item) void DUpdateVisitor::visitMItem(const MItem *item)
{ {
auto ditem = dynamic_cast<DItem *>(m_target); auto ditem = dynamic_cast<DItem *>(m_target);
QMT_CHECK(ditem); QMT_ASSERT(ditem, return);
if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable())) if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable()))
ditem->setShapeEditable(item->isShapeEditable()); ditem->setShapeEditable(item->isShapeEditable());
if (isUpdating(item->variety() != ditem->variety())) if (isUpdating(item->variety() != ditem->variety()))
@@ -146,7 +146,7 @@ void DUpdateVisitor::visitMItem(const MItem *item)
void DUpdateVisitor::visitMRelation(const MRelation *relation) void DUpdateVisitor::visitMRelation(const MRelation *relation)
{ {
auto drelation = dynamic_cast<DRelation *>(m_target); auto drelation = dynamic_cast<DRelation *>(m_target);
QMT_CHECK(drelation); QMT_ASSERT(drelation, return);
if (isUpdating(relation->stereotypes() != drelation->stereotypes())) if (isUpdating(relation->stereotypes() != drelation->stereotypes()))
drelation->setStereotypes(relation->stereotypes()); drelation->setStereotypes(relation->stereotypes());
if (isUpdating(relation->name() != drelation->name())) if (isUpdating(relation->name() != drelation->name()))
@@ -190,7 +190,7 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
void DUpdateVisitor::visitMDependency(const MDependency *dependency) void DUpdateVisitor::visitMDependency(const MDependency *dependency)
{ {
auto ddependency = dynamic_cast<DDependency *>(m_target); auto ddependency = dynamic_cast<DDependency *>(m_target);
QMT_CHECK(ddependency); QMT_ASSERT(ddependency, return);
if (isUpdating(dependency->direction() != ddependency->direction())) if (isUpdating(dependency->direction() != ddependency->direction()))
ddependency->setDirection(dependency->direction()); ddependency->setDirection(dependency->direction());
visitMRelation(dependency); visitMRelation(dependency);
@@ -204,7 +204,7 @@ void DUpdateVisitor::visitMInheritance(const MInheritance *inheritance)
void DUpdateVisitor::visitMAssociation(const MAssociation *association) void DUpdateVisitor::visitMAssociation(const MAssociation *association)
{ {
auto dassociation = dynamic_cast<DAssociation *>(m_target); auto dassociation = dynamic_cast<DAssociation *>(m_target);
QMT_CHECK(dassociation); QMT_ASSERT(dassociation, return);
DAssociationEnd endA; DAssociationEnd endA;
endA.setName(association->endA().name()); endA.setName(association->endA().name());
endA.setCardinatlity(association->endA().cardinality()); endA.setCardinatlity(association->endA().cardinality());

View File

@@ -211,7 +211,7 @@ DSelection DiagramSceneModel::selectedElements() const
DSelection selection; DSelection selection;
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) { foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
DElement *element = m_itemToElementMap.value(item); DElement *element = m_itemToElementMap.value(item);
QMT_CHECK(element); QMT_ASSERT(element, return selection);
selection.append(element->uid(), m_diagram->uid()); selection.append(element->uid(), m_diagram->uid());
} }
return selection; return selection;
@@ -569,8 +569,6 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
} }
} }
break; break;
default:
QMT_CHECK(false);
} }
return collidingItems; return collidingItems;
} }
@@ -649,7 +647,7 @@ void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *e
if (newOwner) { if (newOwner) {
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) { foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
DElement *element = m_itemToElementMap.value(item); DElement *element = m_itemToElementMap.value(item);
QMT_CHECK(element); QMT_ASSERT(element, return);
if (element->modelUid().isValid()) { if (element->modelUid().isValid()) {
MObject *modelObject = modelController->findObject(element->modelUid()); MObject *modelObject = modelController->findObject(element->modelUid());
if (modelObject) { if (modelObject) {
@@ -805,15 +803,15 @@ void DiagramSceneModel::onSelectionChanged()
auto relation = dynamic_cast<DRelation *>(element); auto relation = dynamic_cast<DRelation *>(element);
if (relation) { if (relation) {
QGraphicsItem *relationItem = m_elementToItemMap.value(relation); QGraphicsItem *relationItem = m_elementToItemMap.value(relation);
QMT_CHECK(relationItem); QMT_ASSERT(relationItem, return);
DObject *endAObject = m_diagramController->findElement<DObject>(relation->endAUid(), m_diagram); DObject *endAObject = m_diagramController->findElement<DObject>(relation->endAUid(), m_diagram);
QMT_CHECK(endAObject); QMT_ASSERT(endAObject, return);
QGraphicsItem *endAItem = m_elementToItemMap.value(endAObject); QGraphicsItem *endAItem = m_elementToItemMap.value(endAObject);
QMT_CHECK(endAItem); QMT_ASSERT(endAItem, return);
DObject *endBObject = m_diagramController->findElement<DObject>(relation->endBUid(), m_diagram); DObject *endBObject = m_diagramController->findElement<DObject>(relation->endBUid(), m_diagram);
QMT_CHECK(endBObject); QMT_ASSERT(endBObject, return);
QGraphicsItem *endBItem = m_elementToItemMap.value(endBObject); QGraphicsItem *endBItem = m_elementToItemMap.value(endBObject);
QMT_CHECK(endBItem); QMT_ASSERT(endBItem, return);
if (relationItem && !relationItem->isSelected() if (relationItem && !relationItem->isSelected()
&& (m_selectedItems.contains(endAItem) || newSecondarySelectedItems.contains(endAItem)) && (m_selectedItems.contains(endAItem) || newSecondarySelectedItems.contains(endAItem))
&& (m_selectedItems.contains(endBItem) || newSecondarySelectedItems.contains(endBItem))) { && (m_selectedItems.contains(endBItem) || newSecondarySelectedItems.contains(endBItem))) {
@@ -826,7 +824,7 @@ void DiagramSceneModel::onSelectionChanged()
foreach (QGraphicsItem *item, m_secondarySelectedItems) { foreach (QGraphicsItem *item, m_secondarySelectedItems) {
if (!newSecondarySelectedItems.contains(item)) { if (!newSecondarySelectedItems.contains(item)) {
auto selectable = dynamic_cast<ISelectable *>(item); auto selectable = dynamic_cast<ISelectable *>(item);
QMT_CHECK(selectable); QMT_ASSERT(selectable, return);
selectable->setSecondarySelected(false); selectable->setSecondarySelected(false);
selectionChanged = true; selectionChanged = true;
} }
@@ -834,7 +832,7 @@ void DiagramSceneModel::onSelectionChanged()
foreach (QGraphicsItem *item, newSecondarySelectedItems) { foreach (QGraphicsItem *item, newSecondarySelectedItems) {
if (!m_secondarySelectedItems.contains(item)) { if (!m_secondarySelectedItems.contains(item)) {
auto selectable = dynamic_cast<ISelectable *>(item); auto selectable = dynamic_cast<ISelectable *>(item);
QMT_CHECK(selectable); QMT_ASSERT(selectable, return);
selectable->setSecondarySelected(true); selectable->setSecondarySelected(true);
selectionChanged = true; selectionChanged = true;
} }
@@ -877,7 +875,7 @@ void DiagramSceneModel::addExtraSceneItems()
QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element) QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element)
{ {
QMT_CHECK(element); QMT_ASSERT(element, return nullptr);
QMT_CHECK(!m_elementToItemMap.contains(element)); QMT_CHECK(!m_elementToItemMap.contains(element));
CreationVisitor visitor(this); CreationVisitor visitor(this);
@@ -891,8 +889,8 @@ QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element)
void DiagramSceneModel::updateGraphicsItem(QGraphicsItem *item, DElement *element) void DiagramSceneModel::updateGraphicsItem(QGraphicsItem *item, DElement *element)
{ {
QMT_CHECK(item); QMT_ASSERT(item, return);
QMT_CHECK(element); QMT_ASSERT(element, return);
UpdateVisitor visitor(item, this); UpdateVisitor visitor(item, this);
element->accept(&visitor); element->accept(&visitor);
@@ -945,8 +943,8 @@ void DiagramSceneModel::unsetFocusItem()
bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem) bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem)
{ {
QMT_CHECK(frontItem); QMT_ASSERT(frontItem, return false);
QMT_CHECK(backItem); QMT_ASSERT(backItem, return false);
// shortcut for usual case of root items // shortcut for usual case of root items
if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) { if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) {

View File

@@ -165,11 +165,11 @@ void DiagramSceneModel::UpdateVisitor::visitDObject(DObject *object)
void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package) void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
{ {
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) { if (m_relatedElement == 0) {
PackageItem *packageItem = qgraphicsitem_cast<PackageItem *>(m_graphicsItem); PackageItem *packageItem = qgraphicsitem_cast<PackageItem *>(m_graphicsItem);
QMT_CHECK(packageItem); QMT_ASSERT(packageItem, return);
QMT_CHECK(packageItem->object() == package); QMT_CHECK(packageItem->object() == package);
packageItem->update(); packageItem->update();
} }
@@ -179,11 +179,11 @@ void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass) void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
{ {
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) { if (m_relatedElement == 0) {
ClassItem *classItem = qgraphicsitem_cast<ClassItem *>(m_graphicsItem); ClassItem *classItem = qgraphicsitem_cast<ClassItem *>(m_graphicsItem);
QMT_CHECK(classItem); QMT_ASSERT(classItem, return);
QMT_CHECK(classItem->object() == klass); QMT_CHECK(classItem->object() == klass);
classItem->update(); classItem->update();
} }
@@ -193,11 +193,11 @@ void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component) void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
{ {
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) { if (m_relatedElement == 0) {
ComponentItem *componentItem = qgraphicsitem_cast<ComponentItem *>(m_graphicsItem); ComponentItem *componentItem = qgraphicsitem_cast<ComponentItem *>(m_graphicsItem);
QMT_CHECK(componentItem); QMT_ASSERT(componentItem, return);
QMT_CHECK(componentItem->object() == component); QMT_CHECK(componentItem->object() == component);
componentItem->update(); componentItem->update();
} }
@@ -207,11 +207,11 @@ void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram) void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
{ {
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) { if (m_relatedElement == 0) {
DiagramItem *documentItem = qgraphicsitem_cast<DiagramItem *>(m_graphicsItem); DiagramItem *documentItem = qgraphicsitem_cast<DiagramItem *>(m_graphicsItem);
QMT_CHECK(documentItem); QMT_ASSERT(documentItem, return);
QMT_CHECK(documentItem->object() == diagram); QMT_CHECK(documentItem->object() == diagram);
documentItem->update(); documentItem->update();
} }
@@ -221,11 +221,11 @@ void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item) void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
{ {
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) { if (m_relatedElement == 0) {
ItemItem *itemItem = qgraphicsitem_cast<ItemItem *>(m_graphicsItem); ItemItem *itemItem = qgraphicsitem_cast<ItemItem *>(m_graphicsItem);
QMT_CHECK(itemItem); QMT_ASSERT(itemItem, return);
QMT_CHECK(itemItem->object() == item); QMT_CHECK(itemItem->object() == item);
itemItem->update(); itemItem->update();
} }
@@ -235,13 +235,13 @@ void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
void DiagramSceneModel::UpdateVisitor::visitDRelation(DRelation *relation) void DiagramSceneModel::UpdateVisitor::visitDRelation(DRelation *relation)
{ {
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0 if (m_relatedElement == 0
|| m_relatedElement->uid() == relation->endAUid() || m_relatedElement->uid() == relation->endAUid()
|| m_relatedElement->uid() == relation->endBUid()) { || m_relatedElement->uid() == relation->endBUid()) {
RelationItem *relationItem = qgraphicsitem_cast<RelationItem *>(m_graphicsItem); RelationItem *relationItem = qgraphicsitem_cast<RelationItem *>(m_graphicsItem);
QMT_CHECK(relationItem); QMT_ASSERT(relationItem, return);
QMT_CHECK(relationItem->relation() == relation); QMT_CHECK(relationItem->relation() == relation);
relationItem->update(); relationItem->update();
} }
@@ -265,10 +265,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAssociation(DAssociation *associati
void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation) void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
{ {
Q_UNUSED(annotation); // avoid warning in release mode Q_UNUSED(annotation); // avoid warning in release mode
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
AnnotationItem *annotationItem = qgraphicsitem_cast<AnnotationItem *>(m_graphicsItem); AnnotationItem *annotationItem = qgraphicsitem_cast<AnnotationItem *>(m_graphicsItem);
QMT_CHECK(annotationItem); QMT_ASSERT(annotationItem, return);
QMT_CHECK(annotationItem->annotation() == annotation); QMT_CHECK(annotationItem->annotation() == annotation);
annotationItem->update(); annotationItem->update();
} }
@@ -276,10 +276,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary) void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
{ {
Q_UNUSED(boundary); // avoid warning in release mode Q_UNUSED(boundary); // avoid warning in release mode
QMT_CHECK(m_graphicsItem); QMT_ASSERT(m_graphicsItem, return);
BoundaryItem *boundaryItem = qgraphicsitem_cast<BoundaryItem *>(m_graphicsItem); BoundaryItem *boundaryItem = qgraphicsitem_cast<BoundaryItem *>(m_graphicsItem);
QMT_CHECK(boundaryItem); QMT_ASSERT(boundaryItem, return);
QMT_CHECK(boundaryItem->boundary() == boundary); QMT_CHECK(boundaryItem->boundary() == boundary);
boundaryItem->update(); boundaryItem->update();
} }

View File

@@ -60,7 +60,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
QMT_CHECK(option); QMT_ASSERT(option, return);
QStyleOptionGraphicsItem option2(*option); QStyleOptionGraphicsItem option2(*option);
option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus); option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);

View File

@@ -60,7 +60,7 @@ void AssociationItem::update(const Style *style)
updateEndLabels(m_association->endA(), m_association->endB(), &m_endAName, &m_endACardinality, style); updateEndLabels(m_association->endA(), m_association->endB(), &m_endAName, &m_endACardinality, style);
updateEndLabels(m_association->endB(), m_association->endA(), &m_endBName, &m_endBCardinality, style); updateEndLabels(m_association->endB(), m_association->endA(), &m_endBName, &m_endBCardinality, style);
QMT_CHECK(m_arrow); QMT_ASSERT(m_arrow, return);
QGraphicsItem *endAItem = m_diagramSceneModel->graphicsItem(m_association->endAUid()); QGraphicsItem *endAItem = m_diagramSceneModel->graphicsItem(m_association->endAUid());
if (!endAItem) if (!endAItem)
return; return;

View File

@@ -62,7 +62,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
QMT_CHECK(option); QMT_ASSERT(option, return);
QStyleOptionGraphicsItem option2(*option); QStyleOptionGraphicsItem option2(*option);
option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus); option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);

View File

@@ -82,7 +82,7 @@ void ClassItem::update()
updateStereotypeIconDisplay(); updateStereotypeIconDisplay();
auto diagramClass = dynamic_cast<DClass *>(object()); auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass); QMT_ASSERT(diagramClass, return);
const Style *style = adaptedStyle(stereotypeIconId()); const Style *style = adaptedStyle(stereotypeIconId());
@@ -276,7 +276,7 @@ void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, cons
auto baseClass = dynamic_cast<DClass *>(targetElement); auto baseClass = dynamic_cast<DClass *>(targetElement);
if (baseClass) { if (baseClass) {
auto derivedClass = dynamic_cast<DClass *>(object()); auto derivedClass = dynamic_cast<DClass *>(object());
QMT_CHECK(derivedClass); QMT_ASSERT(derivedClass, return);
diagramSceneModel()->diagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, diagramSceneModel()->diagram()); diagramSceneModel()->diagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, diagramSceneModel()->diagram());
} }
} else if (id == QLatin1String("dependency")) { } else if (id == QLatin1String("dependency")) {
@@ -287,7 +287,7 @@ void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, cons
auto assoziatedClass = dynamic_cast<DClass *>(targetElement); auto assoziatedClass = dynamic_cast<DClass *>(targetElement);
if (assoziatedClass) { if (assoziatedClass) {
auto derivedClass = dynamic_cast<DClass *>(object()); auto derivedClass = dynamic_cast<DClass *>(object());
QMT_CHECK(derivedClass); QMT_ASSERT(derivedClass, return);
diagramSceneModel()->diagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, diagramSceneModel()->diagram()); diagramSceneModel()->diagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, diagramSceneModel()->diagram());
} }
} }
@@ -316,7 +316,7 @@ bool ClassItem::handleSelectedContextMenuAction(const QString &id)
QString ClassItem::buildDisplayName() const QString ClassItem::buildDisplayName() const
{ {
auto diagramClass = dynamic_cast<DClass *>(object()); auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass); QMT_ASSERT(diagramClass, return QString());
QString name; QString name;
if (templateDisplay() == DClass::TemplateName && !diagramClass->templateParameters().isEmpty()) { if (templateDisplay() == DClass::TemplateName && !diagramClass->templateParameters().isEmpty()) {
@@ -344,7 +344,7 @@ void ClassItem::setFromDisplayName(const QString &displayName)
// NOTE namespace is ignored because it has its own edit field // NOTE namespace is ignored because it has its own edit field
if (NameController::parseClassName(displayName, 0, &name, &templateParameters)) { if (NameController::parseClassName(displayName, 0, &name, &templateParameters)) {
auto diagramClass = dynamic_cast<DClass *>(object()); auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass); QMT_ASSERT(diagramClass, return);
ModelController *modelController = diagramSceneModel()->diagramSceneController()->modelController(); ModelController *modelController = diagramSceneModel()->diagramSceneController()->modelController();
MClass *mklass = modelController->findObject<MClass>(diagramClass->modelUid()); MClass *mklass = modelController->findObject<MClass>(diagramClass->modelUid());
if (mklass && (name != mklass->name() || templateParameters != mklass->templateParameters())) { if (mklass && (name != mklass->name() || templateParameters != mklass->templateParameters())) {
@@ -362,7 +362,7 @@ void ClassItem::setFromDisplayName(const QString &displayName)
DClass::TemplateDisplay ClassItem::templateDisplay() const DClass::TemplateDisplay ClassItem::templateDisplay() const
{ {
auto diagramClass = dynamic_cast<DClass *>(object()); auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass); QMT_ASSERT(diagramClass, return DClass::TemplateSmart);
DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay(); DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay();
if (templateDisplay == DClass::TemplateSmart) { if (templateDisplay == DClass::TemplateSmart) {
@@ -560,12 +560,12 @@ void ClassItem::updateMembers(const Style *style)
QString *text = 0; QString *text = 0;
auto dclass = dynamic_cast<DClass *>(object()); auto dclass = dynamic_cast<DClass *>(object());
QMT_CHECK(dclass); QMT_ASSERT(dclass, return);
foreach (const MClassMember &member, dclass->members()) { foreach (const MClassMember &member, dclass->members()) {
switch (member.memberType()) { switch (member.memberType()) {
case MClassMember::MemberUndefined: case MClassMember::MemberUndefined:
QMT_CHECK(false); QMT_ASSERT(false, return);
break; break;
case MClassMember::MemberAttribute: case MClassMember::MemberAttribute:
currentVisibility = &attributesVisibility; currentVisibility = &attributesVisibility;

View File

@@ -237,7 +237,7 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos,
bool ComponentItem::hasPlainShape() const bool ComponentItem::hasPlainShape() const
{ {
auto diagramComponent = dynamic_cast<DComponent *>(object()); auto diagramComponent = dynamic_cast<DComponent *>(object());
QMT_CHECK(diagramComponent); QMT_ASSERT(diagramComponent, return false);
return diagramComponent->isPlainShape(); return diagramComponent->isPlainShape();
} }

View File

@@ -71,7 +71,7 @@ void ItemItem::update()
auto diagramItem = dynamic_cast<DItem *>(object()); auto diagramItem = dynamic_cast<DItem *>(object());
Q_UNUSED(diagramItem); // avoid warning about unsed variable Q_UNUSED(diagramItem); // avoid warning about unsed variable
QMT_CHECK(diagramItem); QMT_ASSERT(diagramItem, return);
const Style *style = adaptedStyle(shapeIconId()); const Style *style = adaptedStyle(shapeIconId());

View File

@@ -674,7 +674,7 @@ bool ObjectItem::showContext() const
// TODO Because of this algorithm adding, moving, removing of one item need to update() all colliding items as well // TODO Because of this algorithm adding, moving, removing of one item need to update() all colliding items as well
QMT_CHECK(object()->modelUid().isValid()); QMT_CHECK(object()->modelUid().isValid());
MObject *mobject = m_diagramSceneModel->diagramController()->modelController()->findObject(object()->modelUid()); MObject *mobject = m_diagramSceneModel->diagramController()->modelController()->findObject(object()->modelUid());
QMT_CHECK(mobject); QMT_ASSERT(mobject, return false);
MObject *owner = mobject->owner(); MObject *owner = mobject->owner();
if (owner) { if (owner) {
foreach (QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingOuterItems)) { foreach (QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingOuterItems)) {
@@ -778,7 +778,7 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
QAction *selectedAction = menu.exec(event->screenPos()); QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction) { if (selectedAction) {
auto action = dynamic_cast<ContextMenuAction *>(selectedAction); auto action = dynamic_cast<ContextMenuAction *>(selectedAction);
QMT_CHECK(action); QMT_ASSERT(action, return);
bool handled = handleSelectedContextMenuAction(action->id()); bool handled = handleSelectedContextMenuAction(action->id());
handled |= element_tasks->handleContextMenuAction(object(), diagramSceneModel()->diagram(), action->id()); handled |= element_tasks->handleContextMenuAction(object(), diagramSceneModel()->diagram(), action->id());
if (!handled) { if (!handled) {

View File

@@ -67,7 +67,7 @@ public:
void visitDInheritance(const DInheritance *inheritance) void visitDInheritance(const DInheritance *inheritance)
{ {
DObject *baseObject = m_diagramSceneModel->diagramController()->findElement<DObject>(inheritance->base(), m_diagramSceneModel->diagram()); DObject *baseObject = m_diagramSceneModel->diagramController()->findElement<DObject>(inheritance->base(), m_diagramSceneModel->diagram());
QMT_CHECK(baseObject); QMT_ASSERT(baseObject, return);
bool baseIsInterface = false; bool baseIsInterface = false;
bool lollipopDisplay = false; bool lollipopDisplay = false;
if (baseObject) { if (baseObject) {
@@ -289,7 +289,7 @@ QPointF RelationItem::grabHandle(int index)
} else { } else {
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints(); QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
--index; --index;
QMT_CHECK(index >= 0 && index < intermediatePoints.size()); QMT_ASSERT(index >= 0 && index < intermediatePoints.size(), return QPointF());
return intermediatePoints.at(index).pos(); return intermediatePoints.at(index).pos();
} }
} }
@@ -337,7 +337,7 @@ void RelationItem::setHandlePos(int index, const QPointF &pos)
} else { } else {
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints(); QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
--index; --index;
QMT_CHECK(index >= 0 && index < intermediatePoints.size()); QMT_ASSERT(index >= 0 && index < intermediatePoints.size(), return);
intermediatePoints[index].setPos(pos); intermediatePoints[index].setPos(pos);
m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateMinor); m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateMinor);
@@ -361,7 +361,7 @@ void RelationItem::dropHandle(int index, double rasterWidth, double rasterHeight
} else { } else {
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints(); QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
--index; --index;
QMT_CHECK(index >= 0 && index < intermediatePoints.size()); QMT_ASSERT(index >= 0 && index < intermediatePoints.size(), return);
QPointF pos = intermediatePoints.at(index).pos(); QPointF pos = intermediatePoints.at(index).pos();
double x = qRound(pos.x() / rasterWidth) * rasterWidth; double x = qRound(pos.x() / rasterWidth) * rasterWidth;
@@ -486,7 +486,7 @@ QPointF RelationItem::calcEndPoint(const Uid &end, const Uid &otherEnd, int near
// otherEndPos will not be used // otherEndPos will not be used
} else { } else {
DObject *endOtherObject = m_diagramSceneModel->diagramController()->findElement<DObject>(otherEnd, m_diagramSceneModel->diagram()); DObject *endOtherObject = m_diagramSceneModel->diagramController()->findElement<DObject>(otherEnd, m_diagramSceneModel->diagram());
QMT_CHECK(endOtherObject); QMT_ASSERT(endOtherObject, return QPointF());
if (endOtherObject) if (endOtherObject)
otherEndPos = endOtherObject->pos(); otherEndPos = endOtherObject->pos();
} }
@@ -502,7 +502,7 @@ QPointF RelationItem::calcEndPoint(const Uid &end, const QPointF &otherEndPos, i
QPointF endPos; QPointF endPos;
if (endObjectItem) { if (endObjectItem) {
DObject *endObject = m_diagramSceneModel->diagramController()->findElement<DObject>(end, m_diagramSceneModel->diagram()); DObject *endObject = m_diagramSceneModel->diagramController()->findElement<DObject>(end, m_diagramSceneModel->diagram());
QMT_CHECK(endObject); QMT_ASSERT(endObject, return QPointF());
bool preferAxis = false; bool preferAxis = false;
QPointF otherPos; QPointF otherPos;
if (nearestIntermediatePointIndex >= 0 && nearestIntermediatePointIndex < m_relation->intermediatePoints().size()) { if (nearestIntermediatePointIndex >= 0 && nearestIntermediatePointIndex < m_relation->intermediatePoints().size()) {

View File

@@ -73,7 +73,7 @@ void LatchController::setDiagramSceneModel(DiagramSceneModel *diagramSceneModel)
void LatchController::addToGraphicsScene(QGraphicsScene *graphicsScene) void LatchController::addToGraphicsScene(QGraphicsScene *graphicsScene)
{ {
QMT_CHECK(graphicsScene); QMT_ASSERT(graphicsScene, return);
graphicsScene->addItem(m_horizontalAlignLine); graphicsScene->addItem(m_horizontalAlignLine);
graphicsScene->addItem(m_verticalAlignLine); graphicsScene->addItem(m_verticalAlignLine);
} }

View File

@@ -346,13 +346,13 @@ QPointF ArrowItem::calcPointAtPercent(double percentage) const
QLineF ArrowItem::firstLineSegment() const QLineF ArrowItem::firstLineSegment() const
{ {
QTC_ASSERT(m_points.size() > 1, return QLineF()); QMT_ASSERT(m_points.size() > 1, return QLineF());
return QLineF(m_points.at(0), m_points.at(1)); return QLineF(m_points.at(0), m_points.at(1));
} }
QLineF ArrowItem::lastLineSegment() const QLineF ArrowItem::lastLineSegment() const
{ {
QTC_ASSERT(m_points.size() > 1, return QLineF()); QMT_ASSERT(m_points.size() > 1, return QLineF());
return QLineF(m_points.at(m_points.size() - 1), m_points.at(m_points.size() - 2)); return QLineF(m_points.at(m_points.size() - 1), m_points.at(m_points.size() - 2));
} }
@@ -380,7 +380,7 @@ void ArrowItem::update(const Style *style)
void ArrowItem::updateShaft(const Style *style) void ArrowItem::updateShaft(const Style *style)
{ {
QTC_ASSERT(m_shaftItem, return); QMT_ASSERT(m_shaftItem, return);
QPen pen(style->linePen()); QPen pen(style->linePen());
if (m_shaft == ShaftDashed) if (m_shaft == ShaftDashed)
@@ -424,8 +424,8 @@ void ArrowItem::updateHeadGeometry(GraphicsHeadItem **headItem, const QPointF &p
void ArrowItem::updateGeometry() void ArrowItem::updateGeometry()
{ {
QTC_ASSERT(m_points.size() > 1, return); QMT_ASSERT(m_points.size() > 1, return);
QTC_ASSERT(m_shaftItem, return); QMT_ASSERT(m_shaftItem, return);
prepareGeometryChange(); prepareGeometryChange();

View File

@@ -207,7 +207,7 @@ QList<QPointF> PathSelectionItem::points() const
void PathSelectionItem::setPoints(const QList<QPointF> &points) void PathSelectionItem::setPoints(const QList<QPointF> &points)
{ {
QMT_CHECK(points.size() >= 2); QMT_ASSERT(points.size() >= 2, return);
prepareGeometryChange(); prepareGeometryChange();
GraphicsHandleItem *focusEndBItem = 0; GraphicsHandleItem *focusEndBItem = 0;

View File

@@ -157,7 +157,7 @@ void RectangularSelectionItem::setSecondarySelected(bool secondarySelected)
void RectangularSelectionItem::update() void RectangularSelectionItem::update()
{ {
QMT_CHECK(HandleFirst == 0 && HandleLast == 7); QMT_ASSERT(HandleFirst == 0 && HandleLast == 7, return);
prepareGeometryChange(); prepareGeometryChange();
for (int i = 0; i <= 7; ++i) { for (int i = 0; i <= 7; ++i) {

View File

@@ -142,13 +142,13 @@ DiagramSceneModel *DiagramsManager::bindDiagramSceneModel(MDiagram *diagram)
DiagramSceneModel *DiagramsManager::diagramSceneModel(const MDiagram *diagram) const DiagramSceneModel *DiagramsManager::diagramSceneModel(const MDiagram *diagram) const
{ {
const ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.value(diagram->uid()); const ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.value(diagram->uid());
QMT_CHECK(managedDiagram); QMT_ASSERT(managedDiagram, return nullptr);
return managedDiagram->diagramSceneModel(); return managedDiagram->diagramSceneModel();
} }
void DiagramsManager::unbindDiagramSceneModel(const MDiagram *diagram) void DiagramsManager::unbindDiagramSceneModel(const MDiagram *diagram)
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.take(diagram->uid()); ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.take(diagram->uid());
QMT_CHECK(managedDiagram); QMT_CHECK(managedDiagram);
delete managedDiagram; delete managedDiagram;

View File

@@ -58,7 +58,7 @@ void DiagramsView::setDiagramsManager(DiagramsManager *diagramsManager)
void DiagramsView::openDiagram(MDiagram *diagram) void DiagramsView::openDiagram(MDiagram *diagram)
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
DiagramView *diagramView = m_diagramViews.value(diagram->uid()); DiagramView *diagramView = m_diagramViews.value(diagram->uid());
if (!diagramView) { if (!diagramView) {
DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram); DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram);

View File

@@ -54,7 +54,7 @@ void StackedDiagramsView::setDiagramsManager(DiagramsManager *diagramsManager)
void StackedDiagramsView::openDiagram(MDiagram *diagram) void StackedDiagramsView::openDiagram(MDiagram *diagram)
{ {
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
DiagramView *diagramView = m_diagramViews.value(diagram->uid()); DiagramView *diagramView = m_diagramViews.value(diagram->uid());
if (!diagramView) { if (!diagramView) {
DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram); DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram);

View File

@@ -86,7 +86,7 @@ public:
bool GeometryUtilities::placeRectAtLine(const QRectF &rect, const QLineF &line, double lineOffset, double distance, bool GeometryUtilities::placeRectAtLine(const QRectF &rect, const QLineF &line, double lineOffset, double distance,
const QLineF &intersectionLine, QPointF *placement, Side *horizontalAlignedSide) const QLineF &intersectionLine, QPointF *placement, Side *horizontalAlignedSide)
{ {
QMT_CHECK(placement); QMT_ASSERT(placement, return false);
QList<Candidate> candidates; QList<Candidate> candidates;
candidates << Candidate(QVector2D(rect.topRight() - rect.topLeft()), QPointF(0.0, 0.0), SideTop) candidates << Candidate(QVector2D(rect.topRight() - rect.topLeft()), QPointF(0.0, 0.0), SideTop)

View File

@@ -86,7 +86,7 @@ public:
bool contains(const T *t) const bool contains(const T *t) const
{ {
QMT_CHECK(t); QMT_ASSERT(t, return false);
return contains(t->uid()); return contains(t->uid());
} }
@@ -101,13 +101,13 @@ public:
T *at(int index) const T *at(int index) const
{ {
QMT_CHECK(index >= 0 && index < m_handleList.size()); QMT_ASSERT(index >= 0 && index < m_handleList.size(), return nullptr);
return m_handleList.at(index).target(); return m_handleList.at(index).target();
} }
T *at(int index) T *at(int index)
{ {
QMT_CHECK(index >= 0 && index < m_handleList.size()); QMT_ASSERT(index >= 0 && index < m_handleList.size(), return nullptr);
return m_handleList.at(index); return m_handleList.at(index);
} }
@@ -124,7 +124,7 @@ public:
int indexOf(const T *t) const int indexOf(const T *t) const
{ {
QMT_CHECK(t); QMT_ASSERT(t, return -1);
return indexOf(t->uid()); return indexOf(t->uid());
} }
@@ -164,27 +164,27 @@ public:
void add(T *t) void add(T *t)
{ {
QMT_CHECK(t); QMT_ASSERT(t, return);
m_handleList.append(Handle<T>(t)); m_handleList.append(Handle<T>(t));
} }
void insert(int beforeIndex, const Uid &uid) void insert(int beforeIndex, const Uid &uid)
{ {
QMT_CHECK(beforeIndex >= 0 && beforeIndex <= m_handleList.size()); QMT_ASSERT(beforeIndex >= 0 && beforeIndex <= m_handleList.size(), return);
QMT_CHECK(uid.isValid()); QMT_ASSERT(uid.isValid(), return);
m_handleList.insert(beforeIndex, Handle<T>(uid)); m_handleList.insert(beforeIndex, Handle<T>(uid));
} }
void insert(int beforeIndex, T *t) void insert(int beforeIndex, T *t)
{ {
QMT_CHECK(beforeIndex >= 0 && beforeIndex <= m_handleList.size()); QMT_ASSERT(beforeIndex >= 0 && beforeIndex <= m_handleList.size(), return);
QMT_CHECK(t); QMT_ASSERT(t, return);
m_handleList.insert(beforeIndex, Handle<T>(t)); m_handleList.insert(beforeIndex, Handle<T>(t));
} }
void remove(int index) void remove(int index)
{ {
QMT_CHECK(index >= 0 && index < size()); QMT_ASSERT(index >= 0 && index < size(), return);
if (m_takesOwnership) { if (m_takesOwnership) {
T *t = m_handleList.at(index).target(); T *t = m_handleList.at(index).target();
m_handleList.removeAt(index); m_handleList.removeAt(index);
@@ -201,13 +201,13 @@ public:
void remove(T *t) void remove(T *t)
{ {
QMT_CHECK(t); QMT_ASSERT(t, return);
remove(indexOf(t)); remove(indexOf(t));
} }
T * take(int index) T * take(int index)
{ {
QMT_CHECK(index >= 0 && index < size()); QMT_ASSERT(index >= 0 && index < size(), return nullptr);
T *t = m_handleList.at(index).target(); T *t = m_handleList.at(index).target();
m_handleList.removeAt(index); m_handleList.removeAt(index);
return t; return t;
@@ -220,7 +220,7 @@ public:
T *take(T *t) T *take(T *t)
{ {
QMT_CHECK(t); QMT_ASSERT(t, return nullptr);
return take(indexOf(t)); return take(indexOf(t));
} }

View File

@@ -60,9 +60,9 @@ void QCompressedDevice::close()
qint64 QCompressedDevice::readData(char *data, qint64 maxlen) qint64 QCompressedDevice::readData(char *data, qint64 maxlen)
{ {
QMT_CHECK(m_targetDevice); QMT_ASSERT(m_targetDevice, return 0);
QMT_CHECK(m_targetDevice->isOpen()); QMT_ASSERT(m_targetDevice->isOpen(), return 0);
QMT_CHECK(m_targetDevice->openMode() == QIODevice::ReadOnly); QMT_ASSERT(m_targetDevice->openMode() == QIODevice::ReadOnly, return 0);
if (m_bytesInBuffer == 0) { if (m_bytesInBuffer == 0) {
QByteArray compressedBuffer; QByteArray compressedBuffer;
@@ -86,9 +86,9 @@ qint64 QCompressedDevice::readData(char *data, qint64 maxlen)
qint64 QCompressedDevice::writeData(const char *data, qint64 len) qint64 QCompressedDevice::writeData(const char *data, qint64 len)
{ {
QMT_CHECK(m_targetDevice); QMT_ASSERT(m_targetDevice, return 0);
QMT_CHECK(m_targetDevice->isOpen()); QMT_ASSERT(m_targetDevice->isOpen(), return 0);
QMT_CHECK(m_targetDevice->openMode() == QIODevice::WriteOnly); QMT_ASSERT(m_targetDevice->openMode() == QIODevice::WriteOnly, return 0);
m_buffer.append(data, len); m_buffer.append(data, len);
if (m_buffer.size() > 1024*1024) { if (m_buffer.size() > 1024*1024) {
@@ -106,8 +106,8 @@ qint64 QCompressedDevice::writeData(const char *data, qint64 len)
qint64 QCompressedDevice::flush() qint64 QCompressedDevice::flush()
{ {
if (openMode() == QIODevice::WriteOnly && m_buffer.size() > 0) { if (openMode() == QIODevice::WriteOnly && m_buffer.size() > 0) {
QMT_CHECK(m_targetDevice->isOpen()); QMT_ASSERT(m_targetDevice->isOpen(), return 0);
QMT_CHECK(m_targetDevice->openMode() == QIODevice::WriteOnly); QMT_ASSERT(m_targetDevice->openMode() == QIODevice::WriteOnly, return 0);
QByteArray compressedBuffer = qCompress(m_buffer); QByteArray compressedBuffer = qCompress(m_buffer);
int compressedLen = static_cast<int>(compressedBuffer.size()); int compressedLen = static_cast<int>(compressedBuffer.size());
if (m_targetDevice->write(reinterpret_cast<const char *>(&compressedLen), sizeof(int)) != sizeof(int)) if (m_targetDevice->write(reinterpret_cast<const char *>(&compressedLen), sizeof(int)) != sizeof(int))

View File

@@ -27,7 +27,7 @@
#include "utils/qtcassert.h" #include "utils/qtcassert.h"
// TODO extend with parameter action
#define QMT_CHECK(condition) QTC_CHECK(condition) #define QMT_CHECK(condition) QTC_CHECK(condition)
#define QMT_ASSERT(condition, action) QTC_ASSERT(condition, action)
// TODO implement logging of where and what // TODO implement logging of where and what
#define QMT_CHECK_X(condition, where, what) QTC_CHECK(condition) #define QMT_CHECK_X(condition, where, what) QMT_CHECK(condition)

View File

@@ -81,21 +81,21 @@ void MDiagram::setDiagramElements(const QList<DElement *> &elements)
void MDiagram::addDiagramElement(DElement *element) void MDiagram::addDiagramElement(DElement *element)
{ {
QMT_CHECK(element); QMT_ASSERT(element, return);
m_elements.append(element); m_elements.append(element);
} }
void MDiagram::insertDiagramElement(int beforeElement, DElement *element) void MDiagram::insertDiagramElement(int beforeElement, DElement *element)
{ {
QMT_CHECK(beforeElement >= 0 && beforeElement <= m_elements.size()); QMT_ASSERT(beforeElement >= 0 && beforeElement <= m_elements.size(), return);
m_elements.insert(beforeElement, element); m_elements.insert(beforeElement, element);
} }
void MDiagram::removeDiagramElement(int index) void MDiagram::removeDiagramElement(int index)
{ {
QMT_CHECK(index >= 0 && index < m_elements.size()); QMT_ASSERT(index >= 0 && index < m_elements.size(), return);
delete m_elements.at(index); delete m_elements.at(index);
m_elements.removeAt(index); m_elements.removeAt(index);
@@ -103,7 +103,7 @@ void MDiagram::removeDiagramElement(int index)
void MDiagram::removeDiagramElement(DElement *element) void MDiagram::removeDiagramElement(DElement *element)
{ {
QMT_CHECK(element); QMT_ASSERT(element, return);
removeDiagramElement(m_elements.indexOf(element)); removeDiagramElement(m_elements.indexOf(element));
} }

View File

@@ -82,8 +82,8 @@ void MObject::addChild(const Uid &uid)
void MObject::addChild(MObject *child) void MObject::addChild(MObject *child)
{ {
QMT_CHECK(child); QMT_ASSERT(child, return);
QMT_CHECK(child->owner() == 0); QMT_ASSERT(child->owner() == 0, return);
m_children.add(child); m_children.add(child);
child->setOwner(this); child->setOwner(this);
} }
@@ -95,15 +95,15 @@ void MObject::insertChild(int beforeIndex, const Uid &uid)
void MObject::insertChild(int beforeIndex, MObject *child) void MObject::insertChild(int beforeIndex, MObject *child)
{ {
QMT_CHECK(child); QMT_ASSERT(child, return);
QMT_CHECK(child->owner() == 0); QMT_ASSERT(child->owner() == 0, return);
m_children.insert(beforeIndex, child); m_children.insert(beforeIndex, child);
child->setOwner(this); child->setOwner(this);
} }
void MObject::removeChild(const Uid &uid) void MObject::removeChild(const Uid &uid)
{ {
QMT_CHECK(m_children.contains(uid)); QMT_ASSERT(m_children.contains(uid), return);
MObject *child = m_children.find(uid); MObject *child = m_children.find(uid);
if (child) if (child)
child->setOwner(0); child->setOwner(0);
@@ -112,15 +112,15 @@ void MObject::removeChild(const Uid &uid)
void MObject::removeChild(MObject *child) void MObject::removeChild(MObject *child)
{ {
QMT_CHECK(child); QMT_ASSERT(child, return);
QMT_CHECK(m_children.contains(child)); QMT_ASSERT(m_children.contains(child), return);
child->setOwner(0); child->setOwner(0);
m_children.remove(child); m_children.remove(child);
} }
void MObject::decontrolChild(const Uid &uid) void MObject::decontrolChild(const Uid &uid)
{ {
QMT_CHECK(m_children.contains(uid)); QMT_ASSERT(m_children.contains(uid), return);
MObject *child = m_children.find(uid); MObject *child = m_children.find(uid);
if (child) if (child)
child->setOwner(0); child->setOwner(0);
@@ -129,8 +129,8 @@ void MObject::decontrolChild(const Uid &uid)
void MObject::decontrolChild(MObject *child) void MObject::decontrolChild(MObject *child)
{ {
QMT_CHECK(child); QMT_ASSERT(child, return);
QMT_CHECK(m_children.contains(child)); QMT_ASSERT(m_children.contains(child), return);
child->setOwner(0); child->setOwner(0);
m_children.take(child); m_children.take(child);
} }
@@ -151,30 +151,30 @@ void MObject::addRelation(const Uid &uid)
void MObject::addRelation(MRelation *relation) void MObject::addRelation(MRelation *relation)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
QMT_CHECK(relation->owner() == 0); QMT_ASSERT(relation->owner() == 0, return);
relation->setOwner(this); relation->setOwner(this);
m_relations.add(relation); m_relations.add(relation);
} }
void MObject::insertRelation(int beforeIndex, MRelation *relation) void MObject::insertRelation(int beforeIndex, MRelation *relation)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
QMT_CHECK(relation->owner() == 0); QMT_ASSERT(relation->owner() == 0, return);
relation->setOwner(this); relation->setOwner(this);
m_relations.insert(beforeIndex, relation); m_relations.insert(beforeIndex, relation);
} }
void MObject::removeRelation(MRelation *relation) void MObject::removeRelation(MRelation *relation)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
relation->setOwner(0); relation->setOwner(0);
m_relations.remove(relation); m_relations.remove(relation);
} }
void MObject::decontrolRelation(MRelation *relation) void MObject::decontrolRelation(MRelation *relation)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
relation->setOwner(0); relation->setOwner(0);
m_relations.take(relation); m_relations.take(relation);
} }

View File

@@ -58,7 +58,7 @@ MSourceExpansion &MSourceExpansion::operator=(const MSourceExpansion &rhs)
MSourceExpansion *MSourceExpansion::clone(const MElement &rhs) const MSourceExpansion *MSourceExpansion::clone(const MElement &rhs) const
{ {
auto rightExpansion = dynamic_cast<MSourceExpansion *>(rhs.expansion()); auto rightExpansion = dynamic_cast<MSourceExpansion *>(rhs.expansion());
QMT_CHECK(rightExpansion); QMT_ASSERT(rightExpansion, return nullptr);
auto expansion = new MSourceExpansion(*rightExpansion); auto expansion = new MSourceExpansion(*rightExpansion);
return expansion; return expansion;
} }

View File

@@ -85,7 +85,7 @@ void MCloneVisitor::visitMDiagram(const MDiagram *diagram)
{ {
QMT_CHECK(m_cloned); QMT_CHECK(m_cloned);
auto cloned = dynamic_cast<MDiagram *>(m_cloned); auto cloned = dynamic_cast<MDiagram *>(m_cloned);
QMT_CHECK(cloned); QMT_ASSERT(cloned, return);
foreach (const DElement *element, diagram->diagramElements()) { foreach (const DElement *element, diagram->diagramElements()) {
DCloneDeepVisitor visitor; DCloneDeepVisitor visitor;
element->accept(&visitor); element->accept(&visitor);
@@ -152,13 +152,13 @@ void MCloneDeepVisitor::visitMObject(const MObject *object)
QMT_CHECK(m_cloned); QMT_CHECK(m_cloned);
visitMElement(object); visitMElement(object);
auto cloned = dynamic_cast<MObject *>(m_cloned); auto cloned = dynamic_cast<MObject *>(m_cloned);
QMT_CHECK(cloned); QMT_ASSERT(cloned, return);
foreach (const Handle<MObject> &handle, object->children()) { foreach (const Handle<MObject> &handle, object->children()) {
if (handle.hasTarget()) { if (handle.hasTarget()) {
MCloneDeepVisitor visitor; MCloneDeepVisitor visitor;
handle.target()->accept(&visitor); handle.target()->accept(&visitor);
auto clonedChild = dynamic_cast<MObject *>(visitor.cloned()); auto clonedChild = dynamic_cast<MObject *>(visitor.cloned());
QMT_CHECK(clonedChild); QMT_ASSERT(clonedChild, return);
cloned->addChild(clonedChild); cloned->addChild(clonedChild);
} else { } else {
cloned->addChild(handle.uid()); cloned->addChild(handle.uid());
@@ -169,7 +169,7 @@ void MCloneDeepVisitor::visitMObject(const MObject *object)
MCloneDeepVisitor visitor; MCloneDeepVisitor visitor;
handle.target()->accept(&visitor); handle.target()->accept(&visitor);
auto clonedRelation = dynamic_cast<MRelation *>(visitor.cloned()); auto clonedRelation = dynamic_cast<MRelation *>(visitor.cloned());
QMT_CHECK(clonedRelation); QMT_ASSERT(clonedRelation, return);
cloned->addRelation(clonedRelation); cloned->addRelation(clonedRelation);
} else { } else {
cloned->addRelation(handle.uid()); cloned->addRelation(handle.uid());
@@ -202,7 +202,7 @@ void MCloneDeepVisitor::visitMDiagram(const MDiagram *diagram)
{ {
QMT_CHECK(m_cloned); QMT_CHECK(m_cloned);
auto cloned = dynamic_cast<MDiagram *>(m_cloned); auto cloned = dynamic_cast<MDiagram *>(m_cloned);
QMT_CHECK(cloned); QMT_ASSERT(cloned, return);
foreach (const DElement *element, diagram->diagramElements()) { foreach (const DElement *element, diagram->diagramElements()) {
DCloneDeepVisitor visitor; DCloneDeepVisitor visitor;
element->accept(&visitor); element->accept(&visitor);
@@ -231,7 +231,7 @@ void MCloneDeepVisitor::visitMRelation(const MRelation *relation)
QMT_CHECK(m_cloned); QMT_CHECK(m_cloned);
visitMElement(relation); visitMElement(relation);
auto cloned = dynamic_cast<MRelation *>(m_cloned); auto cloned = dynamic_cast<MRelation *>(m_cloned);
QMT_CHECK(cloned); QMT_ASSERT(cloned, return);
cloned->setEndAUid(relation->endAUid()); cloned->setEndAUid(relation->endAUid());
cloned->setEndBUid(relation->endBUid()); cloned->setEndBUid(relation->endBUid());
} }

View File

@@ -54,7 +54,7 @@ void MFlatAssignmentVisitor::visitMObject(const MObject *object)
{ {
visitMElement(object); visitMElement(object);
auto targetObject = dynamic_cast<MObject *>(m_target); auto targetObject = dynamic_cast<MObject *>(m_target);
QMT_CHECK(targetObject); QMT_ASSERT(targetObject, return);
targetObject->setName(object->name()); targetObject->setName(object->name());
} }
@@ -67,7 +67,7 @@ void MFlatAssignmentVisitor::visitMClass(const MClass *klass)
{ {
visitMObject(klass); visitMObject(klass);
auto targetClass = dynamic_cast<MClass *>(m_target); auto targetClass = dynamic_cast<MClass *>(m_target);
QMT_CHECK(targetClass); QMT_ASSERT(targetClass, return);
targetClass->setUmlNamespace(klass->umlNamespace()); targetClass->setUmlNamespace(klass->umlNamespace());
targetClass->setTemplateParameters(klass->templateParameters()); targetClass->setTemplateParameters(klass->templateParameters());
targetClass->setMembers(klass->members()); targetClass->setMembers(klass->members());
@@ -82,7 +82,7 @@ void MFlatAssignmentVisitor::visitMDiagram(const MDiagram *diagram)
{ {
visitMObject(diagram); visitMObject(diagram);
auto targetDiagram = dynamic_cast<MDiagram *>(m_target); auto targetDiagram = dynamic_cast<MDiagram *>(m_target);
QMT_CHECK(targetDiagram); QMT_ASSERT(targetDiagram, return);
targetDiagram->setToolbarId(diagram->toolbarId()); targetDiagram->setToolbarId(diagram->toolbarId());
} }
@@ -95,7 +95,7 @@ void MFlatAssignmentVisitor::visitMItem(const MItem *item)
{ {
visitMObject(item); visitMObject(item);
auto targetItem = dynamic_cast<MItem *>(m_target); auto targetItem = dynamic_cast<MItem *>(m_target);
QMT_CHECK(targetItem); QMT_ASSERT(targetItem, return);
targetItem->setVarietyEditable(item->isVarietyEditable()); targetItem->setVarietyEditable(item->isVarietyEditable());
targetItem->setVariety(item->variety()); targetItem->setVariety(item->variety());
targetItem->setShapeEditable(item->isShapeEditable()); targetItem->setShapeEditable(item->isShapeEditable());
@@ -105,7 +105,7 @@ void MFlatAssignmentVisitor::visitMRelation(const MRelation *relation)
{ {
visitMElement(relation); visitMElement(relation);
auto targetRelation = dynamic_cast<MRelation *>(m_target); auto targetRelation = dynamic_cast<MRelation *>(m_target);
QMT_CHECK(targetRelation); QMT_ASSERT(targetRelation, return);
targetRelation->setName(relation->name()); targetRelation->setName(relation->name());
targetRelation->setEndAUid(relation->endAUid()); targetRelation->setEndAUid(relation->endAUid());
targetRelation->setEndBUid(relation->endBUid()); targetRelation->setEndBUid(relation->endBUid());
@@ -115,7 +115,7 @@ void MFlatAssignmentVisitor::visitMDependency(const MDependency *dependency)
{ {
visitMRelation(dependency); visitMRelation(dependency);
auto targetDependency = dynamic_cast<MDependency *>(m_target); auto targetDependency = dynamic_cast<MDependency *>(m_target);
QMT_CHECK(targetDependency); QMT_ASSERT(targetDependency, return);
targetDependency->setDirection(dependency->direction()); targetDependency->setDirection(dependency->direction());
} }
@@ -128,7 +128,7 @@ void MFlatAssignmentVisitor::visitMAssociation(const MAssociation *association)
{ {
visitMRelation(association); visitMRelation(association);
auto targetAssociation = dynamic_cast<MAssociation *>(m_target); auto targetAssociation = dynamic_cast<MAssociation *>(m_target);
QMT_CHECK(targetAssociation); QMT_ASSERT(targetAssociation, return);
targetAssociation->setEndA(association->endA()); targetAssociation->setEndA(association->endA());
targetAssociation->setEndB(association->endB()); targetAssociation->setEndB(association->endB());
} }

View File

@@ -99,7 +99,7 @@ private:
void assign() void assign()
{ {
MObject *object = m_modelController->findObject<MObject>(m_object->uid()); MObject *object = m_modelController->findObject<MObject>(m_object->uid());
QMT_CHECK(object); QMT_ASSERT(object, return);
int row = 0; int row = 0;
MObject *parent = object->owner(); MObject *parent = object->owner();
if (!parent) { if (!parent) {
@@ -173,9 +173,9 @@ private:
void assign() void assign()
{ {
MRelation *relation = m_modelController->findRelation<MRelation>(m_relation->uid()); MRelation *relation = m_modelController->findRelation<MRelation>(m_relation->uid());
QMT_CHECK(relation); QMT_ASSERT(relation, return);
MObject *owner = relation->owner(); MObject *owner = relation->owner();
QMT_CHECK(owner); QMT_ASSERT(owner, return);
int row = owner->relations().indexOf(relation); int row = owner->relations().indexOf(relation);
emit m_modelController->beginUpdateRelation(row, owner); emit m_modelController->beginUpdateRelation(row, owner);
MCloneVisitor cloneVisitor; MCloneVisitor cloneVisitor;
@@ -226,10 +226,10 @@ public:
bool inserted = false; bool inserted = false;
for (int i = m_clonedElements.count() - 1; i >= 0; --i) { for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
Clone &clone = m_clonedElements[i]; Clone &clone = m_clonedElements[i];
QMT_CHECK(clone.m_clonedElement); QMT_ASSERT(clone.m_clonedElement, return);
QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey); QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey);
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey); MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
QMT_CHECK(owner); QMT_ASSERT(owner, return);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_CHECK(clone.m_indexOfElement >= 0);
switch (clone.m_elementType) { switch (clone.m_elementType) {
case TypeObject: case TypeObject:
@@ -275,12 +275,12 @@ public:
Clone &clone = m_clonedElements[i]; Clone &clone = m_clonedElements[i];
QMT_CHECK(!clone.m_clonedElement); QMT_CHECK(!clone.m_clonedElement);
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey); MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
QMT_CHECK(owner); QMT_ASSERT(owner, return);
switch (clone.m_elementType) { switch (clone.m_elementType) {
case TypeObject: case TypeObject:
{ {
MObject *object = m_modelController->findObject<MObject>(clone.m_elementKey); MObject *object = m_modelController->findObject<MObject>(clone.m_elementKey);
QMT_CHECK(object); QMT_ASSERT(object, return);
clone.m_indexOfElement = owner->children().indexOf(object); clone.m_indexOfElement = owner->children().indexOf(object);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_CHECK(clone.m_indexOfElement >= 0);
emit m_modelController->beginRemoveObject(clone.m_indexOfElement, owner); emit m_modelController->beginRemoveObject(clone.m_indexOfElement, owner);
@@ -296,7 +296,7 @@ public:
case TypeRelation: case TypeRelation:
{ {
MRelation *relation = m_modelController->findRelation<MRelation>(clone.m_elementKey); MRelation *relation = m_modelController->findRelation<MRelation>(clone.m_elementKey);
QMT_CHECK(relation); QMT_ASSERT(relation, return);
clone.m_indexOfElement = owner->relations().indexOf(relation); clone.m_indexOfElement = owner->relations().indexOf(relation);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_CHECK(clone.m_indexOfElement >= 0);
emit m_modelController->beginRemoveRelation(clone.m_indexOfElement, owner); emit m_modelController->beginRemoveRelation(clone.m_indexOfElement, owner);
@@ -360,7 +360,7 @@ public:
MCloneDeepVisitor visitor; MCloneDeepVisitor visitor;
element->accept(&visitor); element->accept(&visitor);
clone.m_clonedElement = visitor.cloned(); clone.m_clonedElement = visitor.cloned();
QMT_CHECK(clone.m_clonedElement); QMT_ASSERT(clone.m_clonedElement, return);
m_clonedElements.append(clone); m_clonedElements.append(clone);
} }
@@ -372,12 +372,12 @@ public:
Clone &clone = m_clonedElements[i]; Clone &clone = m_clonedElements[i];
QMT_CHECK(!clone.m_clonedElement); QMT_CHECK(!clone.m_clonedElement);
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey); MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
QMT_CHECK(owner); QMT_ASSERT(owner, return);
switch (clone.m_elementType) { switch (clone.m_elementType) {
case TypeObject: case TypeObject:
{ {
MObject *object = m_modelController->findObject<MObject>(clone.m_elementKey); MObject *object = m_modelController->findObject<MObject>(clone.m_elementKey);
QMT_CHECK(object); QMT_ASSERT(object, return);
clone.m_indexOfElement = owner->children().indexOf(object); clone.m_indexOfElement = owner->children().indexOf(object);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_CHECK(clone.m_indexOfElement >= 0);
emit m_modelController->beginRemoveObject(clone.m_indexOfElement, owner); emit m_modelController->beginRemoveObject(clone.m_indexOfElement, owner);
@@ -393,7 +393,7 @@ public:
case TypeRelation: case TypeRelation:
{ {
MRelation *relation = m_modelController->findRelation<MRelation>(clone.m_elementKey); MRelation *relation = m_modelController->findRelation<MRelation>(clone.m_elementKey);
QMT_CHECK(relation); QMT_ASSERT(relation, return);
clone.m_indexOfElement = owner->relations().indexOf(relation); clone.m_indexOfElement = owner->relations().indexOf(relation);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_CHECK(clone.m_indexOfElement >= 0);
emit m_modelController->beginRemoveRelation(clone.m_indexOfElement, owner); emit m_modelController->beginRemoveRelation(clone.m_indexOfElement, owner);
@@ -423,9 +423,9 @@ public:
bool inserted = false; bool inserted = false;
for (int i = m_clonedElements.count() - 1; i >= 0; --i) { for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
Clone &clone = m_clonedElements[i]; Clone &clone = m_clonedElements[i];
QMT_CHECK(clone.m_clonedElement); QMT_ASSERT(clone.m_clonedElement, return);
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey); MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
QMT_CHECK(owner); QMT_ASSERT(owner, return);
QMT_CHECK(clone.m_indexOfElement >= 0); QMT_CHECK(clone.m_indexOfElement >= 0);
switch (clone.m_elementType) { switch (clone.m_elementType) {
case TypeObject: case TypeObject:
@@ -502,11 +502,11 @@ private:
void swap() void swap()
{ {
MObject *object = m_modelController->findObject(m_objectKey); MObject *object = m_modelController->findObject(m_objectKey);
QMT_CHECK(object); QMT_ASSERT(object, return);
MObject *formerOwner = object->owner(); MObject *formerOwner = object->owner();
int formerRow = formerOwner->children().indexOf(object); int formerRow = formerOwner->children().indexOf(object);
MObject *newOwner = m_modelController->findObject(m_ownerKey); MObject *newOwner = m_modelController->findObject(m_ownerKey);
QMT_CHECK(newOwner); QMT_ASSERT(newOwner, return);
emit m_modelController->beginMoveObject(formerRow, formerOwner); emit m_modelController->beginMoveObject(formerRow, formerOwner);
formerOwner->decontrolChild(object); formerOwner->decontrolChild(object);
newOwner->insertChild(m_indexOfElement, object); newOwner->insertChild(m_indexOfElement, object);
@@ -558,11 +558,11 @@ private:
void swap() void swap()
{ {
MRelation *relation = m_modelController->findRelation(m_relationKey); MRelation *relation = m_modelController->findRelation(m_relationKey);
QMT_CHECK(relation); QMT_ASSERT(relation, return);
MObject *formerOwner = relation->owner(); MObject *formerOwner = relation->owner();
int formerRow = formerOwner->relations().indexOf(relation); int formerRow = formerOwner->relations().indexOf(relation);
MObject *newOwner = m_modelController->findObject(m_ownerKey); MObject *newOwner = m_modelController->findObject(m_ownerKey);
QMT_CHECK(newOwner); QMT_ASSERT(newOwner, return);
emit m_modelController->beginMoveRelation(formerRow, formerOwner); emit m_modelController->beginMoveRelation(formerRow, formerOwner);
formerOwner->decontrolRelation(relation); formerOwner->decontrolRelation(relation);
newOwner->insertRelation(m_indexOfElement, relation); newOwner->insertRelation(m_indexOfElement, relation);
@@ -609,7 +609,7 @@ void ModelController::setUndoController(UndoController *undoController)
Uid ModelController::ownerKey(const MElement *element) const Uid ModelController::ownerKey(const MElement *element) const
{ {
QMT_CHECK(element); QMT_ASSERT(element, return Uid());
MObject *owner = element->owner(); MObject *owner = element->owner();
if (!owner) if (!owner)
return Uid(); return Uid();
@@ -649,7 +649,7 @@ MObject *ModelController::object(int row, const MObject *owner) const
QMT_CHECK(row == 0); QMT_CHECK(row == 0);
return m_rootPackage; return m_rootPackage;
} }
QMT_CHECK(row >= 0 && row < owner->children().size()); QMT_ASSERT(row >= 0 && row < owner->children().size(), return nullptr);
return owner->children().at(row); return owner->children().at(row);
} }
@@ -660,8 +660,8 @@ MObject *ModelController::findObject(const Uid &key) const
void ModelController::addObject(MPackage *parentPackage, MObject *object) void ModelController::addObject(MPackage *parentPackage, MObject *object)
{ {
QMT_CHECK(parentPackage); QMT_ASSERT(parentPackage, return);
QMT_CHECK(object); QMT_ASSERT(object, return);
int row = parentPackage->children().size(); int row = parentPackage->children().size();
if (!m_isResettingModel) if (!m_isResettingModel)
emit beginInsertObject(row, parentPackage); emit beginInsertObject(row, parentPackage);
@@ -681,12 +681,12 @@ void ModelController::addObject(MPackage *parentPackage, MObject *object)
void ModelController::removeObject(MObject *object) void ModelController::removeObject(MObject *object)
{ {
QMT_CHECK(object); QMT_ASSERT(object, return);
if (m_undoController) if (m_undoController)
m_undoController->beginMergeSequence(tr("Delete Object")); m_undoController->beginMergeSequence(tr("Delete Object"));
removeRelatedRelations(object); removeRelatedRelations(object);
// remove object // remove object
QMT_CHECK(object->owner()); QMT_ASSERT(object->owner(), return);
int row = object->owner()->children().indexOf(object); int row = object->owner()->children().indexOf(object);
MObject *owner = object->owner(); MObject *owner = object->owner();
if (!m_isResettingModel) if (!m_isResettingModel)
@@ -709,7 +709,7 @@ void ModelController::removeObject(MObject *object)
void ModelController::startUpdateObject(MObject *object) void ModelController::startUpdateObject(MObject *object)
{ {
QMT_CHECK(object); QMT_ASSERT(object, return);
int row = 0; int row = 0;
MObject *parent = object->owner(); MObject *parent = object->owner();
if (!parent) { if (!parent) {
@@ -727,7 +727,7 @@ void ModelController::startUpdateObject(MObject *object)
void ModelController::finishUpdateObject(MObject *object, bool cancelled) void ModelController::finishUpdateObject(MObject *object, bool cancelled)
{ {
QMT_CHECK(object); QMT_ASSERT(object, return);
int row = 0; int row = 0;
MObject *parent = object->owner(); MObject *parent = object->owner();
@@ -754,14 +754,14 @@ void ModelController::finishUpdateObject(MObject *object, bool cancelled)
void ModelController::moveObject(MPackage *newOwner, MObject *object) void ModelController::moveObject(MPackage *newOwner, MObject *object)
{ {
QMT_CHECK(newOwner); QMT_ASSERT(newOwner, return);
QMT_CHECK(object); QMT_ASSERT(object, return);
QMT_CHECK(object != m_rootPackage); QMT_ASSERT(object != m_rootPackage, return);
if (newOwner != object->owner()) { if (newOwner != object->owner()) {
int formerRow = 0; int formerRow = 0;
MObject *formerOwner = object->owner(); MObject *formerOwner = object->owner();
QMT_CHECK(formerOwner); QMT_ASSERT(formerOwner, return);
formerRow = formerOwner->children().indexOf(object); formerRow = formerOwner->children().indexOf(object);
if (!m_isResettingModel) if (!m_isResettingModel)
emit beginMoveObject(formerRow, formerOwner); emit beginMoveObject(formerRow, formerOwner);
@@ -787,10 +787,10 @@ MRelation *ModelController::findRelation(const Uid &key) const
void ModelController::addRelation(MObject *owner, MRelation *relation) void ModelController::addRelation(MObject *owner, MRelation *relation)
{ {
QMT_CHECK(owner); QMT_ASSERT(owner, return);
QMT_CHECK(relation); QMT_ASSERT(relation, return);
QMT_CHECK(findObject(relation->endAUid())); QMT_ASSERT(findObject(relation->endAUid()), return);
QMT_CHECK(findObject(relation->endBUid())); QMT_ASSERT(findObject(relation->endBUid()), return);
int row = owner->relations().size(); int row = owner->relations().size();
if (!m_isResettingModel) if (!m_isResettingModel)
@@ -811,9 +811,9 @@ void ModelController::addRelation(MObject *owner, MRelation *relation)
void ModelController::removeRelation(MRelation *relation) void ModelController::removeRelation(MRelation *relation)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
MObject *owner = relation->owner(); MObject *owner = relation->owner();
QMT_CHECK(owner); QMT_ASSERT(owner, return);
int row = owner->relations().indexOf(relation); int row = owner->relations().indexOf(relation);
if (!m_isResettingModel) if (!m_isResettingModel)
emit beginRemoveRelation(row, owner); emit beginRemoveRelation(row, owner);
@@ -833,9 +833,9 @@ void ModelController::removeRelation(MRelation *relation)
void ModelController::startUpdateRelation(MRelation *relation) void ModelController::startUpdateRelation(MRelation *relation)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
MObject *owner = relation->owner(); MObject *owner = relation->owner();
QMT_CHECK(owner); QMT_ASSERT(owner, return);
if (!m_isResettingModel) if (!m_isResettingModel)
emit beginUpdateRelation(owner->relations().indexOf(relation), owner); emit beginUpdateRelation(owner->relations().indexOf(relation), owner);
if (m_undoController) if (m_undoController)
@@ -844,11 +844,11 @@ void ModelController::startUpdateRelation(MRelation *relation)
void ModelController::finishUpdateRelation(MRelation *relation, bool cancelled) void ModelController::finishUpdateRelation(MRelation *relation, bool cancelled)
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
QMT_CHECK(findObject(relation->endAUid())); QMT_ASSERT(findObject(relation->endAUid()), return);
QMT_CHECK(findObject(relation->endBUid())); QMT_ASSERT(findObject(relation->endBUid()), return);
MObject *owner = relation->owner(); MObject *owner = relation->owner();
QMT_CHECK(owner); QMT_ASSERT(owner, return);
if (!m_isResettingModel) { if (!m_isResettingModel) {
emit endUpdateRelation(owner->relations().indexOf(relation), owner); emit endUpdateRelation(owner->relations().indexOf(relation), owner);
if (!cancelled) if (!cancelled)
@@ -859,13 +859,13 @@ void ModelController::finishUpdateRelation(MRelation *relation, bool cancelled)
void ModelController::moveRelation(MObject *newOwner, MRelation *relation) void ModelController::moveRelation(MObject *newOwner, MRelation *relation)
{ {
QMT_CHECK(newOwner); QMT_ASSERT(newOwner, return);
QMT_CHECK(relation); QMT_ASSERT(relation, return);
if (newOwner != relation->owner()) { if (newOwner != relation->owner()) {
int formerRow = 0; int formerRow = 0;
MObject *formerOwner = relation->owner(); MObject *formerOwner = relation->owner();
QMT_CHECK(formerOwner); QMT_ASSERT(formerOwner, return);
formerRow = formerOwner->relations().indexOf(relation); formerRow = formerOwner->relations().indexOf(relation);
if (!m_isResettingModel) if (!m_isResettingModel)
emit beginMoveRelation(formerRow, formerOwner); emit beginMoveRelation(formerRow, formerOwner);
@@ -886,7 +886,7 @@ void ModelController::moveRelation(MObject *newOwner, MRelation *relation)
QList<MRelation *> ModelController::findRelationsOfObject(const MObject *object) const QList<MRelation *> ModelController::findRelationsOfObject(const MObject *object) const
{ {
QMT_CHECK(object); QMT_ASSERT(object, return QList<MRelation *>());
return m_objectRelationsMap.values(object->uid()); return m_objectRelationsMap.values(object->uid());
} }
@@ -1135,7 +1135,7 @@ MReferences ModelController::simplify(const MSelection &modelSelection)
MReferences references; MReferences references;
foreach (const MSelection::Index &index, modelSelection.indices()) { foreach (const MSelection::Index &index, modelSelection.indices()) {
MElement *element = findElement(index.elementKey()); MElement *element = findElement(index.elementKey());
QMT_CHECK(element); QMT_ASSERT(element, return MReferences());
// if any (grand-)parent of element is in modelSelection then ignore element // if any (grand-)parent of element is in modelSelection then ignore element
bool ignore = false; bool ignore = false;
MObject *owner = element->owner(); MObject *owner = element->owner();
@@ -1161,28 +1161,28 @@ void ModelController::verifyModelIntegrity() const
{ {
static const bool debugModelIntegrity = false; static const bool debugModelIntegrity = false;
if (debugModelIntegrity) { if (debugModelIntegrity) {
QMT_CHECK(m_rootPackage); QMT_ASSERT(m_rootPackage, return);
QHash<Uid, const MObject *> objectsMap; QHash<Uid, const MObject *> objectsMap;
QHash<Uid, const MRelation *> relationsMap; QHash<Uid, const MRelation *> relationsMap;
QMultiHash<Uid, MRelation *> objectRelationsMap; QMultiHash<Uid, MRelation *> objectRelationsMap;
verifyModelIntegrity(m_rootPackage, &objectsMap, &relationsMap, &objectRelationsMap); verifyModelIntegrity(m_rootPackage, &objectsMap, &relationsMap, &objectRelationsMap);
QMT_CHECK(objectsMap.size() == m_objectsMap.size()); QMT_ASSERT(objectsMap.size() == m_objectsMap.size(), return);
foreach (const MObject *object, m_objectsMap) { foreach (const MObject *object, m_objectsMap) {
QMT_CHECK(object); QMT_ASSERT(object, return);
QMT_CHECK(m_objectsMap.contains(object->uid())); QMT_ASSERT(m_objectsMap.contains(object->uid()), return);
QMT_CHECK(objectsMap.contains(object->uid())); QMT_ASSERT(objectsMap.contains(object->uid()), return);
} }
QMT_CHECK(relationsMap.size() == m_relationsMap.size()); QMT_ASSERT(relationsMap.size() == m_relationsMap.size(), return);
foreach (const MRelation *relation, m_relationsMap) { foreach (const MRelation *relation, m_relationsMap) {
QMT_CHECK(relation); QMT_ASSERT(relation, return);
QMT_CHECK(m_relationsMap.contains(relation->uid())); QMT_ASSERT(m_relationsMap.contains(relation->uid()), return);
QMT_CHECK(relationsMap.contains(relation->uid())); QMT_ASSERT(relationsMap.contains(relation->uid()), return);
} }
QMT_CHECK(objectRelationsMap.size() == m_objectRelationsMap.size()); QMT_ASSERT(objectRelationsMap.size() == m_objectRelationsMap.size(), return);
for (auto it = m_objectRelationsMap.cbegin(); it != m_objectRelationsMap.cend(); ++it) { for (auto it = m_objectRelationsMap.cbegin(); it != m_objectRelationsMap.cend(); ++it) {
QMT_CHECK(objectRelationsMap.contains(it.key(), it.value())); QMT_ASSERT(objectRelationsMap.contains(it.key(), it.value()), return);
} }
} }
} }
@@ -1191,19 +1191,19 @@ void ModelController::verifyModelIntegrity(const MObject *object, QHash<Uid, con
QHash<Uid, const MRelation *> *relationsMap, QHash<Uid, const MRelation *> *relationsMap,
QMultiHash<Uid, MRelation *> *objectRelationsMap) const QMultiHash<Uid, MRelation *> *objectRelationsMap) const
{ {
QMT_CHECK(object); QMT_ASSERT(object, return);
QMT_CHECK(!objectsMap->contains(object->uid())); QMT_ASSERT(!objectsMap->contains(object->uid()), return);
objectsMap->insert(object->uid(), object); objectsMap->insert(object->uid(), object);
foreach (const Handle<MRelation> &handle, object->relations()) { foreach (const Handle<MRelation> &handle, object->relations()) {
MRelation *relation = handle.target(); MRelation *relation = handle.target();
if (relation) { if (relation) {
QMT_CHECK(!relationsMap->contains(relation->uid())); QMT_ASSERT(!relationsMap->contains(relation->uid()), return);
relationsMap->insert(relation->uid(), relation); relationsMap->insert(relation->uid(), relation);
QMT_CHECK(findObject(relation->endAUid())); QMT_ASSERT(findObject(relation->endAUid()), return);
QMT_CHECK(findObject(relation->endBUid())); QMT_ASSERT(findObject(relation->endBUid()), return);
QMT_CHECK(!objectRelationsMap->contains(relation->endAUid(), relation)); QMT_ASSERT(!objectRelationsMap->contains(relation->endAUid(), relation), return);
objectRelationsMap->insert(relation->endAUid(), relation); objectRelationsMap->insert(relation->endAUid(), relation);
QMT_CHECK(!objectRelationsMap->contains(relation->endBUid(), relation)); QMT_ASSERT(!objectRelationsMap->contains(relation->endBUid(), relation), return);
objectRelationsMap->insert(relation->endBUid(), relation); objectRelationsMap->insert(relation->endBUid(), relation);
} }
} }

View File

@@ -86,7 +86,7 @@ public:
void visitMObject(const MObject *object) void visitMObject(const MObject *object)
{ {
Q_UNUSED(object); Q_UNUSED(object);
QMT_CHECK(m_item); QMT_ASSERT(m_item, return);
m_item->setEditable(false); m_item->setEditable(false);
} }
@@ -156,7 +156,7 @@ public:
void visitMRelation(const MRelation *relation) void visitMRelation(const MRelation *relation)
{ {
Q_UNUSED(relation); Q_UNUSED(relation);
QMT_CHECK(m_item); QMT_ASSERT(m_item, return);
m_item->setEditable(false); m_item->setEditable(false);
m_item->setData(TreeModel::Relation, TreeModel::RoleItemType); m_item->setData(TreeModel::Relation, TreeModel::RoleItemType);
} }
@@ -391,13 +391,13 @@ MElement *TreeModel::element(const QModelIndex &index) const
if (item) { if (item) {
if (item->parent()) { if (item->parent()) {
auto parentModelItem = dynamic_cast<ModelItem *>(item->parent()); auto parentModelItem = dynamic_cast<ModelItem *>(item->parent());
QMT_CHECK(parentModelItem); QMT_ASSERT(parentModelItem, return nullptr);
const MObject *parentObject = m_itemToObjectMap.value(parentModelItem); const MObject *parentObject = m_itemToObjectMap.value(parentModelItem);
QMT_CHECK(parentObject); QMT_ASSERT(parentObject, return nullptr);
if (parentObject) { if (parentObject) {
if (index.row() >= 0 && index.row() < parentObject->children().size()) { if (index.row() >= 0 && index.row() < parentObject->children().size()) {
element = parentObject->children().at(index.row()); element = parentObject->children().at(index.row());
QMT_CHECK(element); QMT_ASSERT(element, return nullptr);
} else if (index.row() >= parentObject->children().size() } else if (index.row() >= parentObject->children().size()
&& index.row() < parentObject->children().size() + parentObject->relations().size()) { && index.row() < parentObject->children().size() + parentObject->relations().size()) {
element = parentObject->relations().at(index.row() - parentObject->children().size()); element = parentObject->relations().at(index.row() - parentObject->children().size());
@@ -510,7 +510,7 @@ void TreeModel::onEndUpdateObject(int row, const MObject *parent)
auto object = dynamic_cast<MObject *>(element); auto object = dynamic_cast<MObject *>(element);
if (object) { if (object) {
auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex)); auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex));
QMT_CHECK(item); QMT_ASSERT(item, return);
ItemUpdater visitor(this, item); ItemUpdater visitor(this, item);
element->accept(&visitor); element->accept(&visitor);
} }
@@ -531,7 +531,7 @@ void TreeModel::onEndInsertObject(int row, const MObject *parent)
{ {
QMT_CHECK(m_busyState == InsertElement); QMT_CHECK(m_busyState == InsertElement);
ModelItem *parentItem =m_objectToItemMap.value(parent); ModelItem *parentItem =m_objectToItemMap.value(parent);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
MObject *object = parent->children().at(row); MObject *object = parent->children().at(row);
ModelItem *item = createItem(object); ModelItem *item = createItem(object);
parentItem->insertRow(row, item); parentItem->insertRow(row, item);
@@ -542,13 +542,13 @@ void TreeModel::onEndInsertObject(int row, const MObject *parent)
void TreeModel::onBeginRemoveObject(int row, const MObject *parent) void TreeModel::onBeginRemoveObject(int row, const MObject *parent)
{ {
QMT_CHECK(m_busyState == NotBusy); QMT_CHECK(m_busyState == NotBusy);
QMT_ASSERT(parent, return);
m_busyState = RemoveElement; m_busyState = RemoveElement;
QMT_CHECK(parent);
MObject *object = parent->children().at(row); MObject *object = parent->children().at(row);
if (object) if (object)
removeObjectFromItemMap(object); removeObjectFromItemMap(object);
ModelItem *parentItem = m_objectToItemMap.value(parent); ModelItem *parentItem = m_objectToItemMap.value(parent);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
parentItem->removeRow(row); parentItem->removeRow(row);
} }
@@ -563,13 +563,13 @@ void TreeModel::onEndRemoveObject(int row, const MObject *parent)
void TreeModel::onBeginMoveObject(int formerRow, const MObject *formerOwner) void TreeModel::onBeginMoveObject(int formerRow, const MObject *formerOwner)
{ {
QMT_CHECK(m_busyState == NotBusy); QMT_CHECK(m_busyState == NotBusy);
QMT_ASSERT(formerOwner, return);
m_busyState = MoveElement; m_busyState = MoveElement;
QMT_CHECK(formerOwner);
MObject *object = formerOwner->children().at(formerRow); MObject *object = formerOwner->children().at(formerRow);
if (object) if (object)
removeObjectFromItemMap(object); removeObjectFromItemMap(object);
ModelItem *parentItem = m_objectToItemMap.value(formerOwner); ModelItem *parentItem = m_objectToItemMap.value(formerOwner);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
parentItem->removeRow(formerRow); parentItem->removeRow(formerRow);
} }
@@ -577,7 +577,7 @@ void TreeModel::onEndMoveObject(int row, const MObject *owner)
{ {
QMT_CHECK(m_busyState == MoveElement); QMT_CHECK(m_busyState == MoveElement);
ModelItem *parentItem =m_objectToItemMap.value(owner); ModelItem *parentItem =m_objectToItemMap.value(owner);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
MObject *object = owner->children().at(row); MObject *object = owner->children().at(row);
ModelItem *item = createItem(object); ModelItem *item = createItem(object);
parentItem->insertRow(row, item); parentItem->insertRow(row, item);
@@ -595,12 +595,12 @@ void TreeModel::onBeginUpdateRelation(int row, const MObject *parent)
void TreeModel::onEndUpdateRelation(int row, const MObject *parent) void TreeModel::onEndUpdateRelation(int row, const MObject *parent)
{ {
QMT_CHECK(parent); QMT_ASSERT(parent, return);
QMT_CHECK(m_busyState == UpdateRelation); QMT_CHECK(m_busyState == UpdateRelation);
QMT_CHECK(m_objectToItemMap.contains(parent)); QMT_CHECK(m_objectToItemMap.contains(parent));
ModelItem *parentItem = m_objectToItemMap.value(parent); ModelItem *parentItem = m_objectToItemMap.value(parent);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
QModelIndex parentIndex = indexFromItem(parentItem); QModelIndex parentIndex = indexFromItem(parentItem);
// reflect updated relation in standard item // reflect updated relation in standard item
@@ -611,7 +611,7 @@ void TreeModel::onEndUpdateRelation(int row, const MObject *parent)
auto relation = dynamic_cast<MRelation *>(element); auto relation = dynamic_cast<MRelation *>(element);
if (relation) { if (relation) {
auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex)); auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex));
QMT_CHECK(item); QMT_ASSERT(item, return);
ItemUpdater visitor(this, item); ItemUpdater visitor(this, item);
element->accept(&visitor); element->accept(&visitor);
} }
@@ -630,10 +630,10 @@ void TreeModel::onBeginInsertRelation(int row, const MObject *parent)
void TreeModel::onEndInsertRelation(int row, const MObject *parent) void TreeModel::onEndInsertRelation(int row, const MObject *parent)
{ {
QMT_CHECK(parent); QMT_ASSERT(parent, return);
QMT_CHECK(m_busyState == InsertRelation); QMT_CHECK(m_busyState == InsertRelation);
ModelItem *parentItem =m_objectToItemMap.value(parent); ModelItem *parentItem =m_objectToItemMap.value(parent);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
MRelation *relation = parent->relations().at(row); MRelation *relation = parent->relations().at(row);
ModelItem *item = createItem(relation); ModelItem *item = createItem(relation);
parentItem->insertRow(parent->children().size() + row, item); parentItem->insertRow(parent->children().size() + row, item);
@@ -642,12 +642,12 @@ void TreeModel::onEndInsertRelation(int row, const MObject *parent)
void TreeModel::onBeginRemoveRelation(int row, const MObject *parent) void TreeModel::onBeginRemoveRelation(int row, const MObject *parent)
{ {
QMT_CHECK(parent); QMT_ASSERT(parent, return);
QMT_CHECK(m_busyState == NotBusy); QMT_CHECK(m_busyState == NotBusy);
m_busyState = RemoveRelation; m_busyState = RemoveRelation;
QMT_CHECK(parent->relations().at(row)); QMT_CHECK(parent->relations().at(row));
ModelItem *parentItem = m_objectToItemMap.value(parent); ModelItem *parentItem = m_objectToItemMap.value(parent);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
parentItem->removeRow(parent->children().size() + row); parentItem->removeRow(parent->children().size() + row);
} }
@@ -662,20 +662,20 @@ void TreeModel::onEndRemoveRelation(int row, const MObject *parent)
void TreeModel::onBeginMoveRelation(int formerRow, const MObject *formerOwner) void TreeModel::onBeginMoveRelation(int formerRow, const MObject *formerOwner)
{ {
QMT_CHECK(m_busyState == NotBusy); QMT_CHECK(m_busyState == NotBusy);
QMT_ASSERT(formerOwner, return);
m_busyState = MoveElement; m_busyState = MoveElement;
QMT_CHECK(formerOwner);
QMT_CHECK(formerOwner->relations().at(formerRow)); QMT_CHECK(formerOwner->relations().at(formerRow));
ModelItem *parentItem = m_objectToItemMap.value(formerOwner); ModelItem *parentItem = m_objectToItemMap.value(formerOwner);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
parentItem->removeRow(formerOwner->children().size() + formerRow); parentItem->removeRow(formerOwner->children().size() + formerRow);
} }
void TreeModel::onEndMoveRelation(int row, const MObject *owner) void TreeModel::onEndMoveRelation(int row, const MObject *owner)
{ {
QMT_CHECK(owner); QMT_ASSERT(owner, return);
QMT_CHECK(m_busyState == MoveElement); QMT_CHECK(m_busyState == MoveElement);
ModelItem *parentItem =m_objectToItemMap.value(owner); ModelItem *parentItem =m_objectToItemMap.value(owner);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
MRelation *relation = owner->relations().at(row); MRelation *relation = owner->relations().at(row);
ModelItem *item = createItem(relation); ModelItem *item = createItem(relation);
parentItem->insertRow(owner->children().size() + row, item); parentItem->insertRow(owner->children().size() + row, item);
@@ -688,10 +688,10 @@ void TreeModel::onRelationEndChanged(MRelation *relation, MObject *endObject)
QMT_CHECK(m_busyState == NotBusy); QMT_CHECK(m_busyState == NotBusy);
MObject *parent = relation->owner(); MObject *parent = relation->owner();
QMT_CHECK(parent); QMT_ASSERT(parent, return);
QMT_CHECK(m_objectToItemMap.contains(parent)); QMT_CHECK(m_objectToItemMap.contains(parent));
ModelItem *parentItem = m_objectToItemMap.value(parent); ModelItem *parentItem = m_objectToItemMap.value(parent);
QMT_CHECK(parentItem); QMT_ASSERT(parentItem, return);
QModelIndex parentIndex = indexFromItem(parentItem); QModelIndex parentIndex = indexFromItem(parentItem);
int row = parent->children().size() + relation->owner()->relations().indexOf(relation); int row = parent->children().size() + relation->owner()->relations().indexOf(relation);
@@ -699,7 +699,7 @@ void TreeModel::onRelationEndChanged(MRelation *relation, MObject *endObject)
QMT_CHECK(elementIndex.isValid()); QMT_CHECK(elementIndex.isValid());
auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex)); auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex));
QMT_CHECK(item); QMT_ASSERT(item, return);
QString label = createRelationLabel(relation); QString label = createRelationLabel(relation);
if (item->text() != label) if (item->text() != label)
@@ -758,10 +758,10 @@ void TreeModel::createChildren(const MObject *parentObject, ModelItem *parentIte
void TreeModel::removeObjectFromItemMap(const MObject *object) void TreeModel::removeObjectFromItemMap(const MObject *object)
{ {
QMT_CHECK(object); QMT_ASSERT(object, return);
QMT_CHECK(m_objectToItemMap.contains(object)); QMT_CHECK(m_objectToItemMap.contains(object));
ModelItem *item = m_objectToItemMap.value(object); ModelItem *item = m_objectToItemMap.value(object);
QMT_CHECK(item); QMT_ASSERT(item, return);
QMT_CHECK(m_itemToObjectMap.contains(item)); QMT_CHECK(m_itemToObjectMap.contains(item));
m_itemToObjectMap.remove(item); m_itemToObjectMap.remove(item);
m_objectToItemMap.remove(object); m_objectToItemMap.remove(object);
@@ -773,7 +773,7 @@ void TreeModel::removeObjectFromItemMap(const MObject *object)
QString TreeModel::createObjectLabel(const MObject *object) QString TreeModel::createObjectLabel(const MObject *object)
{ {
QMT_CHECK(object); QMT_ASSERT(object, return QString());
if (object->name().isEmpty()) { if (object->name().isEmpty()) {
if (auto item = dynamic_cast<const MItem *>(object)) { if (auto item = dynamic_cast<const MItem *>(object)) {

View File

@@ -84,7 +84,7 @@ MPackage *TreeModelManager::selectedPackage() const
if (m_modelTreeView->currentSourceModelIndex().isValid()) if (m_modelTreeView->currentSourceModelIndex().isValid())
{ {
MElement *element = m_treeModel->element(m_modelTreeView->currentSourceModelIndex()); MElement *element = m_treeModel->element(m_modelTreeView->currentSourceModelIndex());
QMT_CHECK(element); QMT_ASSERT(element, return nullptr);
if (auto package = dynamic_cast<MPackage *>(element)) { if (auto package = dynamic_cast<MPackage *>(element)) {
return package; return package;
} else if (auto object = dynamic_cast<MObject *>(element)) { } else if (auto object = dynamic_cast<MObject *>(element)) {

View File

@@ -452,7 +452,7 @@ QString ClassMembersEdit::build(const QList<MClassMember> &members)
QList<MClassMember> ClassMembersEdit::parse(const QString &text, bool *ok) QList<MClassMember> ClassMembersEdit::parse(const QString &text, bool *ok)
{ {
QMT_CHECK(ok); QMT_ASSERT(ok, return QList<MClassMember>());
*ok = true; *ok = true;
QList<MClassMember> members; QList<MClassMember> members;

View File

@@ -113,7 +113,7 @@ void ModelTreeView::startDrag(Qt::DropActions supportedActions)
Q_UNUSED(supportedActions); Q_UNUSED(supportedActions);
TreeModel *treeModel = m_sortedTreeModel->treeModel(); TreeModel *treeModel = m_sortedTreeModel->treeModel();
QMT_CHECK(treeModel); QMT_ASSERT(treeModel, return);
QByteArray dragData; QByteArray dragData;
QDataStream dataStream(&dragData, QIODevice::WriteOnly); QDataStream dataStream(&dragData, QIODevice::WriteOnly);
@@ -170,7 +170,7 @@ void ModelTreeView::dragMoveEvent(QDragMoveEvent *event)
QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex); QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex);
if (dropSourceModelIndex.isValid()) { if (dropSourceModelIndex.isValid()) {
TreeModel *treeModel = m_sortedTreeModel->treeModel(); TreeModel *treeModel = m_sortedTreeModel->treeModel();
QMT_CHECK(treeModel); QMT_ASSERT(treeModel, return);
MElement *modelElement = treeModel->element(dropSourceModelIndex); MElement *modelElement = treeModel->element(dropSourceModelIndex);
if (dynamic_cast<MObject*>(modelElement)) if (dynamic_cast<MObject*>(modelElement))
accept = true; accept = true;
@@ -202,7 +202,7 @@ void ModelTreeView::dropEvent(QDropEvent *event)
QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex); QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex);
if (dropSourceModelIndex.isValid()) { if (dropSourceModelIndex.isValid()) {
TreeModel *treeModel = m_sortedTreeModel->treeModel(); TreeModel *treeModel = m_sortedTreeModel->treeModel();
QMT_CHECK(treeModel); QMT_ASSERT(treeModel, return);
MElement *targetModelElement = treeModel->element(dropSourceModelIndex); MElement *targetModelElement = treeModel->element(dropSourceModelIndex);
if (auto targetModelObject = dynamic_cast<MObject *>(targetModelElement)) { if (auto targetModelObject = dynamic_cast<MObject *>(targetModelElement)) {
QDataStream dataStream(event->mimeData()->data(QStringLiteral("text/model-elements"))); QDataStream dataStream(event->mimeData()->data(QStringLiteral("text/model-elements")));
@@ -245,9 +245,9 @@ void ModelTreeView::contextMenuEvent(QContextMenuEvent *event)
QModelIndex sourceModelIndex = m_sortedTreeModel->mapToSource(index); QModelIndex sourceModelIndex = m_sortedTreeModel->mapToSource(index);
if (sourceModelIndex.isValid()) { if (sourceModelIndex.isValid()) {
TreeModel *treeModel = m_sortedTreeModel->treeModel(); TreeModel *treeModel = m_sortedTreeModel->treeModel();
QMT_CHECK(treeModel); QMT_ASSERT(treeModel, return);
MElement *melement = treeModel->element(sourceModelIndex); MElement *melement = treeModel->element(sourceModelIndex);
QMT_CHECK(melement); QMT_ASSERT(melement, return);
QMenu menu; QMenu menu;
bool addSeparator = false; bool addSeparator = false;
@@ -268,7 +268,7 @@ void ModelTreeView::contextMenuEvent(QContextMenuEvent *event)
QAction *selectedAction = menu.exec(event->globalPos()); QAction *selectedAction = menu.exec(event->globalPos());
if (selectedAction) { if (selectedAction) {
auto action = dynamic_cast<ContextMenuAction *>(selectedAction); auto action = dynamic_cast<ContextMenuAction *>(selectedAction);
QMT_CHECK(action); QMT_ASSERT(action, return);
if (action->id() == QStringLiteral("showDefinition")) { if (action->id() == QStringLiteral("showDefinition")) {
m_elementTasks->openClassDefinition(melement); m_elementTasks->openClassDefinition(melement);
} else if (action->id() == QStringLiteral("openDiagram")) { } else if (action->id() == QStringLiteral("openDiagram")) {

View File

@@ -47,13 +47,13 @@ PaletteBox::~PaletteBox()
QBrush PaletteBox::brush(int index) const QBrush PaletteBox::brush(int index) const
{ {
QMT_CHECK(index >= 0 && index <= m_brushes.size()); QMT_ASSERT(index >= 0 && index <= m_brushes.size(), return QBrush());
return m_brushes.at(index); return m_brushes.at(index);
} }
void PaletteBox::setBrush(int index, const QBrush &brush) void PaletteBox::setBrush(int index, const QBrush &brush)
{ {
QMT_CHECK(index >= 0 && index <= m_brushes.size()); QMT_ASSERT(index >= 0 && index <= m_brushes.size(), return);
if (m_brushes[index] != brush) { if (m_brushes[index] != brush) {
m_brushes[index] = brush; m_brushes[index] = brush;
update(); update();
@@ -62,13 +62,13 @@ void PaletteBox::setBrush(int index, const QBrush &brush)
QPen PaletteBox::linePen(int index) const QPen PaletteBox::linePen(int index) const
{ {
QMT_CHECK(index >= 0 && index <= m_pens.size()); QMT_ASSERT(index >= 0 && index <= m_pens.size(), return QPen());
return m_pens.at(index); return m_pens.at(index);
} }
void PaletteBox::setLinePen(int index, const QPen &pen) void PaletteBox::setLinePen(int index, const QPen &pen)
{ {
QMT_CHECK(index >= 0 && index <= m_pens.size()); QMT_ASSERT(index >= 0 && index <= m_pens.size(), return);
if (m_pens[index] != pen) { if (m_pens[index] != pen) {
m_pens[index] = pen; m_pens[index] = pen;
update(); update();
@@ -125,7 +125,7 @@ void PaletteBox::mousePressEvent(QMouseEvent *event)
qreal w = static_cast<qreal>(width()) / static_cast<qreal>(m_brushes.size()); qreal w = static_cast<qreal>(width()) / static_cast<qreal>(m_brushes.size());
int i = static_cast<int>((event->x() / w)); int i = static_cast<int>((event->x() / w));
QMT_CHECK(i >= 0 && i < m_brushes.size()); QMT_ASSERT(i >= 0 && i < m_brushes.size(), return);
setCurrentIndex(i); setCurrentIndex(i);
if (m_currentIndex >= 0 && m_currentIndex < m_brushes.size()) if (m_currentIndex >= 0 && m_currentIndex < m_brushes.size())
emit activated(m_currentIndex); emit activated(m_currentIndex);

View File

@@ -172,7 +172,7 @@ void PropertiesView::setSelectedModelElements(const QList<MElement *> &modelElem
void PropertiesView::setSelectedDiagramElements(const QList<DElement *> &diagramElements, MDiagram *diagram) void PropertiesView::setSelectedDiagramElements(const QList<DElement *> &diagramElements, MDiagram *diagram)
{ {
QMT_CHECK(diagramElements.size() > 0); QMT_CHECK(diagramElements.size() > 0);
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
if (m_selectedDiagramElements != diagramElements || m_selectedDiagram != diagram) { if (m_selectedDiagramElements != diagramElements || m_selectedDiagram != diagram) {
m_selectedDiagramElements = diagramElements; m_selectedDiagramElements = diagramElements;
@@ -386,7 +386,7 @@ void PropertiesView::onEndRemoveElement(int row, const MDiagram *diagram)
void PropertiesView::beginUpdate(MElement *modelElement) void PropertiesView::beginUpdate(MElement *modelElement)
{ {
QMT_CHECK(modelElement); QMT_ASSERT(modelElement, return);
if (auto object = dynamic_cast<MObject *>(modelElement)) { if (auto object = dynamic_cast<MObject *>(modelElement)) {
m_modelController->startUpdateObject(object); m_modelController->startUpdateObject(object);
@@ -399,7 +399,7 @@ void PropertiesView::beginUpdate(MElement *modelElement)
void PropertiesView::endUpdate(MElement *modelElement, bool cancelled) void PropertiesView::endUpdate(MElement *modelElement, bool cancelled)
{ {
QMT_CHECK(modelElement); QMT_ASSERT(modelElement, return);
if (auto object = dynamic_cast<MObject *>(modelElement)) { if (auto object = dynamic_cast<MObject *>(modelElement)) {
m_modelController->finishUpdateObject(object, cancelled); m_modelController->finishUpdateObject(object, cancelled);
@@ -412,18 +412,18 @@ void PropertiesView::endUpdate(MElement *modelElement, bool cancelled)
void PropertiesView::beginUpdate(DElement *diagramElement) void PropertiesView::beginUpdate(DElement *diagramElement)
{ {
QMT_CHECK(diagramElement); QMT_ASSERT(diagramElement, return);
QMT_CHECK(m_selectedDiagram != 0); QMT_ASSERT(m_selectedDiagram, return);
QMT_CHECK(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement); QMT_ASSERT(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement, return);
m_diagramController->startUpdateElement(diagramElement, m_selectedDiagram, DiagramController::UpdateMinor); m_diagramController->startUpdateElement(diagramElement, m_selectedDiagram, DiagramController::UpdateMinor);
} }
void PropertiesView::endUpdate(DElement *diagramElement, bool cancelled) void PropertiesView::endUpdate(DElement *diagramElement, bool cancelled)
{ {
QMT_CHECK(diagramElement); QMT_ASSERT(diagramElement, return);
QMT_CHECK(m_selectedDiagram != 0); QMT_ASSERT(m_selectedDiagram, return);
QMT_CHECK(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement); QMT_ASSERT(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement, return);
m_diagramController->finishUpdateElement(diagramElement, m_selectedDiagram, cancelled); m_diagramController->finishUpdateElement(diagramElement, m_selectedDiagram, cancelled);
} }

View File

@@ -102,7 +102,7 @@ static MDependency::Direction translateIndexToDirection(int index)
static const MDependency::Direction map[] = { static const MDependency::Direction map[] = {
MDependency::AToB, MDependency::BToA, MDependency::Bidirectional MDependency::AToB, MDependency::BToA, MDependency::Bidirectional
}; };
QMT_CHECK(isValidDirectionIndex(index)); QMT_ASSERT(isValidDirectionIndex(index), return MDependency::AToB);
return map[index]; return map[index];
} }
@@ -129,7 +129,7 @@ static MAssociationEnd::Kind translateIndexToAssociationKind(int index)
static const MAssociationEnd::Kind map[] = { static const MAssociationEnd::Kind map[] = {
MAssociationEnd::Association, MAssociationEnd::Aggregation, MAssociationEnd::Composition MAssociationEnd::Association, MAssociationEnd::Aggregation, MAssociationEnd::Composition
}; };
QMT_CHECK(isValidAssociationKindIndex(index)); QMT_ASSERT(isValidAssociationKindIndex(index), return MAssociationEnd::Association);
return map[index]; return map[index];
} }
@@ -164,7 +164,7 @@ static DObject::VisualPrimaryRole translateIndexToVisualPrimaryRole(int index)
DObject::PrimaryRoleCustom1, DObject::PrimaryRoleCustom2, DObject::PrimaryRoleCustom3, DObject::PrimaryRoleCustom1, DObject::PrimaryRoleCustom2, DObject::PrimaryRoleCustom3,
DObject::PrimaryRoleCustom4, DObject::PrimaryRoleCustom5 DObject::PrimaryRoleCustom4, DObject::PrimaryRoleCustom5
}; };
QMT_CHECK(index >= 0 && index <= 5); QMT_ASSERT(index >= 0 && index <= 5, return DObject::PrimaryRoleNormal);
return map[index]; return map[index];
} }
@@ -192,7 +192,7 @@ static DObject::VisualSecondaryRole translateIndexToVisualSecondaryRole(int inde
DObject::SecondaryRoleLighter, DObject::SecondaryRoleDarker, DObject::SecondaryRoleLighter, DObject::SecondaryRoleDarker,
DObject::SecondaryRoleSoften, DObject::SecondaryRoleOutline DObject::SecondaryRoleSoften, DObject::SecondaryRoleOutline
}; };
QMT_CHECK(index >= 0 && index <= 4); QMT_ASSERT(index >= 0 && index <= 4, return DObject::SecondaryRoleNone);
return map[index]; return map[index];
} }
@@ -222,7 +222,7 @@ static DObject::StereotypeDisplay translateIndexToStereotypeDisplay(int index)
DObject::StereotypeDecoration, DObject::StereotypeDecoration,
DObject::StereotypeIcon DObject::StereotypeIcon
}; };
QMT_CHECK(index >= 0 && index <= 4); QMT_ASSERT(index >= 0 && index <= 4, return DObject::StereotypeSmart);
return map[index]; return map[index];
} }
@@ -246,7 +246,7 @@ static DClass::TemplateDisplay translateIndexToTemplateDisplay(int index)
DClass::TemplateBox, DClass::TemplateBox,
DClass::TemplateName DClass::TemplateName
}; };
QMT_CHECK(index >= 0 && index <= 2); QMT_ASSERT(index >= 0 && index <= 2, return DClass::TemplateSmart);
return map[index]; return map[index];
} }
@@ -275,7 +275,7 @@ static DAnnotation::VisualRole translateIndexToAnnotationVisualRole(int index)
DAnnotation::RoleNormal, DAnnotation::RoleTitle, DAnnotation::RoleSubtitle, DAnnotation::RoleNormal, DAnnotation::RoleTitle, DAnnotation::RoleSubtitle,
DAnnotation::RoleEmphasized, DAnnotation::RoleSoften, DAnnotation::RoleFootnote DAnnotation::RoleEmphasized, DAnnotation::RoleSoften, DAnnotation::RoleFootnote
}; };
QMT_CHECK(index >= 0 && index <= 5); QMT_ASSERT(index >= 0 && index <= 5, return DAnnotation::RoleNormal);
return map[index]; return map[index];
} }
@@ -334,7 +334,7 @@ PropertiesView::MView::~MView()
void PropertiesView::MView::update(QList<MElement *> &modelElements) void PropertiesView::MView::update(QList<MElement *> &modelElements)
{ {
QMT_CHECK(modelElements.size() > 0); QMT_ASSERT(modelElements.size() > 0, return);
m_modelElements = modelElements; m_modelElements = modelElements;
m_diagramElements.clear(); m_diagramElements.clear();
@@ -344,8 +344,8 @@ void PropertiesView::MView::update(QList<MElement *> &modelElements)
void PropertiesView::MView::update(QList<DElement *> &diagramElements, MDiagram *diagram) void PropertiesView::MView::update(QList<DElement *> &diagramElements, MDiagram *diagram)
{ {
QMT_CHECK(diagramElements.size() > 0); QMT_ASSERT(diagramElements.size() > 0, return);
QMT_CHECK(diagram); QMT_ASSERT(diagram, return);
m_diagramElements = diagramElements; m_diagramElements = diagramElements;
m_diagram = diagram; m_diagram = diagram;
@@ -599,10 +599,10 @@ void PropertiesView::MView::visitMRelation(const MRelation *relation)
if (m_elementNameLineEdit->isEnabled() != isSingleSelection) if (m_elementNameLineEdit->isEnabled() != isSingleSelection)
m_elementNameLineEdit->setEnabled(isSingleSelection); m_elementNameLineEdit->setEnabled(isSingleSelection);
MObject *endAObject = m_propertiesView->modelController()->findObject(relation->endAUid()); MObject *endAObject = m_propertiesView->modelController()->findObject(relation->endAUid());
QMT_CHECK(endAObject); QMT_ASSERT(endAObject, return);
setEndAName(tr("End A: %1").arg(endAObject->name())); setEndAName(tr("End A: %1").arg(endAObject->name()));
MObject *endBObject = m_propertiesView->modelController()->findObject(relation->endBUid()); MObject *endBObject = m_propertiesView->modelController()->findObject(relation->endBUid());
QMT_CHECK(endBObject); QMT_ASSERT(endBObject, return);
setEndBName(tr("End B: %1").arg(endBObject->name())); setEndBName(tr("End B: %1").arg(endBObject->name()));
} }
@@ -636,10 +636,10 @@ void PropertiesView::MView::visitMInheritance(const MInheritance *inheritance)
{ {
setTitle<MInheritance>(m_modelElements, tr("Inheritance"), tr("Inheritances")); setTitle<MInheritance>(m_modelElements, tr("Inheritance"), tr("Inheritances"));
MObject *derivedClass = m_propertiesView->modelController()->findObject(inheritance->derived()); MObject *derivedClass = m_propertiesView->modelController()->findObject(inheritance->derived());
QMT_CHECK(derivedClass); QMT_ASSERT(derivedClass, return);
setEndAName(tr("Derived class: %1").arg(derivedClass->name())); setEndAName(tr("Derived class: %1").arg(derivedClass->name()));
MObject *baseClass = m_propertiesView->modelController()->findObject(inheritance->base()); MObject *baseClass = m_propertiesView->modelController()->findObject(inheritance->base());
QMT_CHECK(baseClass); QMT_ASSERT(baseClass, return);
setEndBName(tr("Base class: %1").arg(baseClass->name())); setEndBName(tr("Base class: %1").arg(baseClass->name()));
visitMRelation(inheritance); visitMRelation(inheritance);
} }

View File

@@ -72,7 +72,7 @@ ProjectSerializer::~ProjectSerializer()
void ProjectSerializer::save(const QString &fileName, const Project *project) void ProjectSerializer::save(const QString &fileName, const Project *project)
{ {
QMT_CHECK(project); QMT_ASSERT(project, return);
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) if (!file.open(QIODevice::WriteOnly))
@@ -108,7 +108,7 @@ QByteArray ProjectSerializer::save(const Project *project)
void ProjectSerializer::load(const QString &fileName, Project *project) void ProjectSerializer::load(const QString &fileName, Project *project)
{ {
QMT_CHECK(project); QMT_ASSERT(project, return);
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))

View File

@@ -510,7 +510,7 @@ QColor DefaultStyleEngine::baseColor(ElementType elementType, ObjectVisuals obje
}; };
int index = static_cast<int>(objectVisuals.visualPrimaryRole()) - static_cast<int>(DObject::PrimaryRoleCustom1); int index = static_cast<int>(objectVisuals.visualPrimaryRole()) - static_cast<int>(DObject::PrimaryRoleCustom1);
QMT_CHECK(index >= 0 && index <= 4); QMT_ASSERT(index >= 0 && index <= 4, return baseColor);
baseColor = customColors[index]; baseColor = customColors[index];
} }

View File

@@ -150,10 +150,10 @@ void DiagramSceneController::deleteFromDiagram(const DSelection &dselection, MDi
DSelection remainingDselection; DSelection remainingDselection;
foreach (const DSelection::Index &index, dselection.indices()) { foreach (const DSelection::Index &index, dselection.indices()) {
DElement *delement = m_diagramController->findElement(index.elementKey(), diagram); DElement *delement = m_diagramController->findElement(index.elementKey(), diagram);
QMT_CHECK(delement); QMT_ASSERT(delement, return);
if (delement->modelUid().isValid()) { if (delement->modelUid().isValid()) {
MElement *melement = m_modelController->findElement(delement->modelUid()); MElement *melement = m_modelController->findElement(delement->modelUid());
QMT_CHECK(melement); QMT_ASSERT(melement, return);
if (melement->owner()) if (melement->owner())
mselection.append(melement->uid(), melement->owner()->uid()); mselection.append(melement->uid(), melement->owner()->uid());
} else { } else {
@@ -173,9 +173,9 @@ void DiagramSceneController::createDependency(DObject *endAObject, DObject *endB
m_diagramController->undoController()->beginMergeSequence(tr("Create Dependency")); m_diagramController->undoController()->beginMergeSequence(tr("Create Dependency"));
MObject *endAModelObject = m_modelController->findObject<MObject>(endAObject->modelUid()); MObject *endAModelObject = m_modelController->findObject<MObject>(endAObject->modelUid());
QMT_CHECK(endAModelObject); QMT_ASSERT(endAModelObject, return);
MObject *endBModelObject = m_modelController->findObject<MObject>(endBObject->modelUid()); MObject *endBModelObject = m_modelController->findObject<MObject>(endBObject->modelUid());
QMT_CHECK(endBModelObject); QMT_ASSERT(endBModelObject, return);
if (endAModelObject == endBModelObject) if (endAModelObject == endBModelObject)
return; return;
@@ -200,9 +200,9 @@ void DiagramSceneController::createInheritance(DClass *derivedClass, DClass *bas
m_diagramController->undoController()->beginMergeSequence(tr("Create Inheritance")); m_diagramController->undoController()->beginMergeSequence(tr("Create Inheritance"));
MClass *derivedModelClass = m_modelController->findObject<MClass>(derivedClass->modelUid()); MClass *derivedModelClass = m_modelController->findObject<MClass>(derivedClass->modelUid());
QMT_CHECK(derivedModelClass); QMT_ASSERT(derivedModelClass, return);
MClass *baseModelClass = m_modelController->findObject<MClass>(baseClass->modelUid()); MClass *baseModelClass = m_modelController->findObject<MClass>(baseClass->modelUid());
QMT_CHECK(baseModelClass); QMT_ASSERT(baseModelClass, return);
if (derivedModelClass == baseModelClass) if (derivedModelClass == baseModelClass)
return; return;
@@ -226,9 +226,9 @@ void DiagramSceneController::createAssociation(DClass *endAClass, DClass *endBCl
m_diagramController->undoController()->beginMergeSequence(tr("Create Association")); m_diagramController->undoController()->beginMergeSequence(tr("Create Association"));
MClass *endAModelObject = m_modelController->findObject<MClass>(endAClass->modelUid()); MClass *endAModelObject = m_modelController->findObject<MClass>(endAClass->modelUid());
QMT_CHECK(endAModelObject); QMT_ASSERT(endAModelObject, return);
MClass *endBModelObject = m_modelController->findObject<MClass>(endBClass->modelUid()); MClass *endBModelObject = m_modelController->findObject<MClass>(endBClass->modelUid());
QMT_CHECK(endBModelObject); QMT_ASSERT(endBModelObject, return);
// TODO allow self assignment with just one intermediate point and a nice round arrow // TODO allow self assignment with just one intermediate point and a nice round arrow
if (endAModelObject == endBModelObject && intermediatePoints.count() < 2) if (endAModelObject == endBModelObject && intermediatePoints.count() < 2)
@@ -263,18 +263,18 @@ bool DiagramSceneController::relocateRelationEndB(DRelation *relation, DObject *
bool DiagramSceneController::isAddingAllowed(const Uid &modelElementKey, MDiagram *diagram) bool DiagramSceneController::isAddingAllowed(const Uid &modelElementKey, MDiagram *diagram)
{ {
MElement *modelElement = m_modelController->findElement(modelElementKey); MElement *modelElement = m_modelController->findElement(modelElementKey);
QMT_CHECK(modelElement); QMT_ASSERT(modelElement, return false);
if (m_diagramController->hasDelegate(modelElement, diagram)) if (m_diagramController->hasDelegate(modelElement, diagram))
return false; return false;
if (auto modelRelation = dynamic_cast<MRelation *>(modelElement)) { if (auto modelRelation = dynamic_cast<MRelation *>(modelElement)) {
MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid()); MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid());
QMT_CHECK(endAModelObject); QMT_ASSERT(endAModelObject, return false);
DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram); DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram);
if (!endADiagramObject) if (!endADiagramObject)
return false; return false;
MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid()); MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid());
QMT_CHECK(endBModelObject); QMT_ASSERT(endBModelObject, return false);
DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram); DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram);
if (!endBDiagramObject) if (!endBDiagramObject)
return false; return false;
@@ -595,7 +595,7 @@ DElement *DiagramSceneController::addModelElement(const Uid &modelElementKey, co
DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &pos, MDiagram *diagram) DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &pos, MDiagram *diagram)
{ {
QMT_CHECK(modelObject); QMT_ASSERT(modelObject, return nullptr);
if (m_diagramController->hasDelegate(modelObject, diagram)) if (m_diagramController->hasDelegate(modelObject, diagram))
return 0; return 0;
@@ -605,7 +605,7 @@ DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &
DFactory factory; DFactory factory;
modelObject->accept(&factory); modelObject->accept(&factory);
auto diagramObject = dynamic_cast<DObject *>(factory.product()); auto diagramObject = dynamic_cast<DObject *>(factory.product());
QMT_CHECK(diagramObject); QMT_ASSERT(diagramObject, return nullptr);
diagramObject->setPos(pos); diagramObject->setPos(pos);
m_diagramController->addElement(diagramObject, diagram); m_diagramController->addElement(diagramObject, diagram);
alignOnRaster(diagramObject, diagram); alignOnRaster(diagramObject, diagram);
@@ -657,7 +657,7 @@ DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &
DRelation *DiagramSceneController::addRelation(MRelation *modelRelation, const QList<QPointF> &intermediatePoints, DRelation *DiagramSceneController::addRelation(MRelation *modelRelation, const QList<QPointF> &intermediatePoints,
MDiagram *diagram) MDiagram *diagram)
{ {
QMT_CHECK(modelRelation); QMT_ASSERT(modelRelation, return nullptr);
if (m_diagramController->hasDelegate(modelRelation, diagram)) if (m_diagramController->hasDelegate(modelRelation, diagram))
return 0; return 0;
@@ -665,18 +665,18 @@ DRelation *DiagramSceneController::addRelation(MRelation *modelRelation, const Q
DFactory factory; DFactory factory;
modelRelation->accept(&factory); modelRelation->accept(&factory);
auto diagramRelation = dynamic_cast<DRelation *>(factory.product()); auto diagramRelation = dynamic_cast<DRelation *>(factory.product());
QMT_CHECK(diagramRelation); QMT_ASSERT(diagramRelation, return nullptr);
MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid()); MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid());
QMT_CHECK(endAModelObject); QMT_ASSERT(endAModelObject, return nullptr);
DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram); DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram);
QMT_CHECK(endADiagramObject); QMT_ASSERT(endADiagramObject, return nullptr);
diagramRelation->setEndAUid(endADiagramObject->uid()); diagramRelation->setEndAUid(endADiagramObject->uid());
MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid()); MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid());
QMT_CHECK(endBModelObject); QMT_ASSERT(endBModelObject, return nullptr);
DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram); DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram);
QMT_CHECK(endBDiagramObject); QMT_ASSERT(endBDiagramObject, return nullptr);
diagramRelation->setEndBUid(endBDiagramObject->uid()); diagramRelation->setEndBUid(endBDiagramObject->uid());
QList<DRelation::IntermediatePoint> relationPoints; QList<DRelation::IntermediatePoint> relationPoints;
@@ -712,17 +712,17 @@ bool DiagramSceneController::relocateRelationEnd(DRelation *relation, DObject *t
Uid (MRelation::*endUid)() const, Uid (MRelation::*endUid)() const,
void (MRelation::*setEndUid)(const Uid &)) void (MRelation::*setEndUid)(const Uid &))
{ {
QMT_CHECK(relation); QMT_ASSERT(relation, return false);
if (targetObject && targetObject->uid() != relation->endAUid()) { if (targetObject && targetObject->uid() != relation->endAUid()) {
MRelation *modelRelation = m_modelController->findRelation(relation->modelUid()); MRelation *modelRelation = m_modelController->findRelation(relation->modelUid());
QMT_CHECK(modelRelation); QMT_ASSERT(modelRelation, return false);
MObject *targetMObject = m_modelController->findObject(targetObject->modelUid()); MObject *targetMObject = m_modelController->findObject(targetObject->modelUid());
QMT_CHECK(targetMObject); QMT_ASSERT(targetMObject, return false);
AcceptRelationVisitor visitor(modelRelation); AcceptRelationVisitor visitor(modelRelation);
targetMObject->accept(&visitor); targetMObject->accept(&visitor);
if (visitor.isAccepted()) { if (visitor.isAccepted()) {
MObject *currentTargetMObject = m_modelController->findObject((modelRelation->*endUid)()); MObject *currentTargetMObject = m_modelController->findObject((modelRelation->*endUid)());
QMT_CHECK(currentTargetMObject); QMT_ASSERT(currentTargetMObject, return false);
m_modelController->undoController()->beginMergeSequence(tr("Relocate Relation")); m_modelController->undoController()->beginMergeSequence(tr("Relocate Relation"));
// move relation into new target if it was a child of the old target // move relation into new target if it was a child of the old target
if (currentTargetMObject == modelRelation->owner()) if (currentTargetMObject == modelRelation->owner())

View File

@@ -190,7 +190,7 @@ void UpdateIncludeDependenciesVisitor::visitMComponent(qmt::MComponent *componen
int componentHighestAncestorIndex = componentAncestors.size() - 1; int componentHighestAncestorIndex = componentAncestors.size() - 1;
int includeComponentHighestAncestorIndex = includeComponentAncestors.size() - 1; int includeComponentHighestAncestorIndex = includeComponentAncestors.size() - 1;
QTC_ASSERT(componentAncestors.at(componentHighestAncestorIndex) == includeComponentAncestors.at(includeComponentHighestAncestorIndex), return); QMT_ASSERT(componentAncestors.at(componentHighestAncestorIndex) == includeComponentAncestors.at(includeComponentHighestAncestorIndex), return);
while (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) { while (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) {
if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex)) if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex))
break; break;

View File

@@ -401,7 +401,7 @@ void ElementTasks::createAndOpenDiagram(const qmt::MElement *element)
auto newDiagram = new qmt::MCanvasDiagram(); auto newDiagram = new qmt::MCanvasDiagram();
newDiagram->setName(package->name()); newDiagram->setName(package->name());
qmt::MPackage *parentPackage = d->documentController->modelController()->findObject<qmt::MPackage>(package->uid()); qmt::MPackage *parentPackage = d->documentController->modelController()->findObject<qmt::MPackage>(package->uid());
QTC_ASSERT(parentPackage, delete newDiagram; return); QMT_ASSERT(parentPackage, delete newDiagram; return);
d->documentController->modelController()->addObject(parentPackage, newDiagram); d->documentController->modelController()->addObject(parentPackage, newDiagram);
ModelEditorPlugin::modelsManager()->openDiagram( ModelEditorPlugin::modelsManager()->openDiagram(
d->documentController->projectController()->project()->uid(), d->documentController->projectController()->project()->uid(),

View File

@@ -363,7 +363,7 @@ void ModelEditor::initDocument()
d->diagramView->setPxNodeController(documentController->pxNodeController()); d->diagramView->setPxNodeController(documentController->pxNodeController());
QTC_CHECK(!d->diagramsViewManager); QMT_CHECK(!d->diagramsViewManager);
d->diagramsViewManager = new DiagramsViewManager(this); d->diagramsViewManager = new DiagramsViewManager(this);
//connect(diagramsViewManager, &DiagramsViewManager::someDiagramOpened, //connect(diagramsViewManager, &DiagramsViewManager::someDiagramOpened,
// documentController->diagramsManager(), &qmt::DiagramsManager::someDiagramOpened); // documentController->diagramsManager(), &qmt::DiagramsManager::someDiagramOpened);
@@ -767,7 +767,7 @@ void ModelEditor::clearProperties()
if (d->propertiesGroupWidget) { if (d->propertiesGroupWidget) {
QWidget *scrollWidget = d->propertiesScrollArea->takeWidget(); QWidget *scrollWidget = d->propertiesScrollArea->takeWidget();
Q_UNUSED(scrollWidget); // avoid warning in release mode Q_UNUSED(scrollWidget); // avoid warning in release mode
QTC_CHECK(scrollWidget == d->propertiesGroupWidget); QMT_CHECK(scrollWidget == d->propertiesGroupWidget);
d->propertiesGroupWidget->deleteLater(); d->propertiesGroupWidget->deleteLater();
d->propertiesGroupWidget = 0; d->propertiesGroupWidget = 0;
} }
@@ -801,8 +801,8 @@ QToolButton *ModelEditor::createToolbarCommandButton(const Core::Id &id, const s
bool ModelEditor::updateButtonIconByTheme(QAbstractButton *button, const QString &name) bool ModelEditor::updateButtonIconByTheme(QAbstractButton *button, const QString &name)
{ {
QTC_ASSERT(button, return false); QMT_ASSERT(button, return false);
QTC_ASSERT(!name.isEmpty(), return false); QMT_ASSERT(!name.isEmpty(), return false);
if (QIcon::hasThemeIcon(name)) { if (QIcon::hasThemeIcon(name)) {
button->setIcon(QIcon::fromTheme(name)); button->setIcon(QIcon::fromTheme(name));
@@ -1015,7 +1015,7 @@ void ModelEditor::initToolbars()
toolBars.insert(toolbar.id(), toolBar); toolBars.insert(toolbar.id(), toolBar);
} else { } else {
toolBarLayout = toolBar->layout(); toolBarLayout = toolBar->layout();
QTC_ASSERT(toolBarLayout, continue); QMT_ASSERT(toolBarLayout, continue);
} }
foreach (const qmt::Toolbar::Tool &tool, toolbar.tools()) { foreach (const qmt::Toolbar::Tool &tool, toolbar.tools()) {
switch (tool.m_toolType) { switch (tool.m_toolType) {
@@ -1115,9 +1115,9 @@ void ModelEditor::initToolbars()
// add stretch to all layouts and calculate width of tool bar // add stretch to all layouts and calculate width of tool bar
int maxWidth = 48; int maxWidth = 48;
foreach (QWidget *toolBar, toolBars) { foreach (QWidget *toolBar, toolBars) {
QTC_ASSERT(toolBar, continue); QMT_ASSERT(toolBar, continue);
auto layout = qobject_cast<QBoxLayout *>(toolBar->layout()); auto layout = qobject_cast<QBoxLayout *>(toolBar->layout());
QTC_ASSERT(layout, continue); QMT_ASSERT(layout, continue);
layout->addStretch(1); layout->addStretch(1);
toolBar->adjustSize(); toolBar->adjustSize();
if (maxWidth < toolBar->width()) if (maxWidth < toolBar->width())

View File

@@ -233,12 +233,12 @@ class ModelIndexer::ModelIndexerPrivate
public: public:
~ModelIndexerPrivate() ~ModelIndexerPrivate()
{ {
QTC_CHECK(filesQueue.isEmpty()); QMT_CHECK(filesQueue.isEmpty());
QTC_CHECK(queuedFilesSet.isEmpty()); QMT_CHECK(queuedFilesSet.isEmpty());
QTC_CHECK(indexedModels.isEmpty()); QMT_CHECK(indexedModels.isEmpty());
QTC_CHECK(indexedModelsByUid.isEmpty()); QMT_CHECK(indexedModelsByUid.isEmpty());
QTC_CHECK(indexedDiagramReferences.isEmpty()); QMT_CHECK(indexedDiagramReferences.isEmpty());
QTC_CHECK(indexedDiagramReferencesByDiagramUid.isEmpty()); QMT_CHECK(indexedDiagramReferencesByDiagramUid.isEmpty());
delete indexerThread; delete indexerThread;
} }
@@ -344,7 +344,7 @@ QString ModelIndexer::findModel(const qmt::Uid &modelUid)
if (indexedModels.isEmpty()) if (indexedModels.isEmpty())
return QString(); return QString();
IndexedModel *indexedModel = *indexedModels.cbegin(); IndexedModel *indexedModel = *indexedModels.cbegin();
QTC_ASSERT(indexedModel, return QString()); QMT_ASSERT(indexedModel, return QString());
return indexedModel->file(); return indexedModel->file();
} }
@@ -357,8 +357,8 @@ QString ModelIndexer::findDiagram(const qmt::Uid &modelUid, const qmt::Uid &diag
if (indexedDiagramReferences.isEmpty()) if (indexedDiagramReferences.isEmpty())
return QString(); return QString();
IndexedDiagramReference *indexedDiagramReference = *indexedDiagramReferences.cbegin(); IndexedDiagramReference *indexedDiagramReference = *indexedDiagramReferences.cbegin();
QTC_ASSERT(indexedDiagramReference, return QString()); QMT_ASSERT(indexedDiagramReference, return QString());
QTC_ASSERT(indexedDiagramReference->modelUid() == modelUid, return QString()); QMT_ASSERT(indexedDiagramReference->modelUid() == modelUid, return QString());
return indexedDiagramReference->file(); return indexedDiagramReference->file();
} }
@@ -434,7 +434,7 @@ void ModelIndexer::scanProject(ProjectExplorer::Project *project)
while (!filesQueue.isEmpty()) { while (!filesQueue.isEmpty()) {
QueuedFile queuedFile = filesQueue.takeFirst(); QueuedFile queuedFile = filesQueue.takeFirst();
if (!d->queuedFilesSet.contains(queuedFile)) { if (!d->queuedFilesSet.contains(queuedFile)) {
QTC_CHECK(!d->filesQueue.contains(queuedFile)); QMT_CHECK(!d->filesQueue.contains(queuedFile));
d->filesQueue.append(queuedFile); d->filesQueue.append(queuedFile);
d->queuedFilesSet.insert(queuedFile); d->queuedFilesSet.insert(queuedFile);
filesAreQueued = true; filesAreQueued = true;
@@ -475,9 +475,9 @@ void ModelIndexer::forgetProject(ProjectExplorer::Project *project)
// remove file from queue // remove file from queue
QueuedFile queuedFile(file, project); QueuedFile queuedFile(file, project);
if (d->queuedFilesSet.contains(queuedFile)) { if (d->queuedFilesSet.contains(queuedFile)) {
QTC_CHECK(d->filesQueue.contains(queuedFile)); QMT_CHECK(d->filesQueue.contains(queuedFile));
d->filesQueue.removeOne(queuedFile); d->filesQueue.removeOne(queuedFile);
QTC_CHECK(!d->filesQueue.contains(queuedFile)); QMT_CHECK(!d->filesQueue.contains(queuedFile));
d->queuedFilesSet.remove(queuedFile); d->queuedFilesSet.remove(queuedFile);
} }
removeModelFile(file, project); removeModelFile(file, project);
@@ -497,9 +497,9 @@ void ModelIndexer::removeModelFile(const QString &file, ProjectExplorer::Project
d->indexedModels.remove(file); d->indexedModels.remove(file);
// remove indexedModel from set of indexedModelsByUid // remove indexedModel from set of indexedModelsByUid
QTC_CHECK(d->indexedModelsByUid.contains(indexedModel->modelUid())); QMT_CHECK(d->indexedModelsByUid.contains(indexedModel->modelUid()));
QSet<IndexedModel *> indexedModels = d->indexedModelsByUid.value(indexedModel->modelUid()); QSet<IndexedModel *> indexedModels = d->indexedModelsByUid.value(indexedModel->modelUid());
QTC_CHECK(indexedModels.contains(indexedModel)); QMT_CHECK(indexedModels.contains(indexedModel));
indexedModels.remove(indexedModel); indexedModels.remove(indexedModel);
if (indexedModels.isEmpty()) if (indexedModels.isEmpty())
d->indexedModelsByUid.remove(indexedModel->modelUid()); d->indexedModelsByUid.remove(indexedModel->modelUid());
@@ -516,7 +516,7 @@ void ModelIndexer::removeDiagramReferenceFile(const QString &file,
{ {
IndexedDiagramReference *indexedDiagramReference = d->indexedDiagramReferences.value(file); IndexedDiagramReference *indexedDiagramReference = d->indexedDiagramReferences.value(file);
if (indexedDiagramReference) { if (indexedDiagramReference) {
QTC_CHECK(indexedDiagramReference->owningProjects().contains(project)); QMT_CHECK(indexedDiagramReference->owningProjects().contains(project));
qCDebug(logger) << "remove diagram reference file " qCDebug(logger) << "remove diagram reference file "
<< file << " from project " << project->displayName(); << file << " from project " << project->displayName();
indexedDiagramReference->removeOwningProject(project); indexedDiagramReference->removeOwningProject(project);
@@ -525,9 +525,9 @@ void ModelIndexer::removeDiagramReferenceFile(const QString &file,
d->indexedDiagramReferences.remove(file); d->indexedDiagramReferences.remove(file);
// remove indexedDiagramReference from set of indexedDiagramReferecesByDiagramUid // remove indexedDiagramReference from set of indexedDiagramReferecesByDiagramUid
QTC_CHECK(d->indexedDiagramReferencesByDiagramUid.contains(indexedDiagramReference->diagramUid())); QMT_CHECK(d->indexedDiagramReferencesByDiagramUid.contains(indexedDiagramReference->diagramUid()));
QSet<IndexedDiagramReference *> indexedDiagramReferences = d->indexedDiagramReferencesByDiagramUid.value(indexedDiagramReference->diagramUid()); QSet<IndexedDiagramReference *> indexedDiagramReferences = d->indexedDiagramReferencesByDiagramUid.value(indexedDiagramReference->diagramUid());
QTC_CHECK(indexedDiagramReferences.contains(indexedDiagramReference)); QMT_CHECK(indexedDiagramReferences.contains(indexedDiagramReference));
indexedDiagramReferences.remove(indexedDiagramReference); indexedDiagramReferences.remove(indexedDiagramReference);
if (indexedDiagramReferences.isEmpty()) { if (indexedDiagramReferences.isEmpty()) {
d->indexedDiagramReferencesByDiagramUid.remove( d->indexedDiagramReferencesByDiagramUid.remove(

View File

@@ -123,7 +123,7 @@ ModelsManager::ModelsManager(QObject *parent)
ModelsManager::~ModelsManager() ModelsManager::~ModelsManager()
{ {
QTC_CHECK(d->managedModels.isEmpty()); QMT_CHECK(d->managedModels.isEmpty());
delete d->modelIndexer; delete d->modelIndexer;
delete d; delete d;
} }
@@ -150,7 +150,7 @@ void ModelsManager::releaseModel(ExtDocumentController *documentController)
return; return;
} }
} }
QTC_CHECK(false); QMT_CHECK(false);
} }
void ModelsManager::openDiagram(const qmt::Uid &modelUid, const qmt::Uid &diagramUid) void ModelsManager::openDiagram(const qmt::Uid &modelUid, const qmt::Uid &diagramUid)
@@ -158,7 +158,7 @@ void ModelsManager::openDiagram(const qmt::Uid &modelUid, const qmt::Uid &diagra
foreach (const ManagedModel &managedModel, d->managedModels) { foreach (const ManagedModel &managedModel, d->managedModels) {
if (managedModel.m_documentController->projectController()->project()->uid() == modelUid) { if (managedModel.m_documentController->projectController()->project()->uid() == modelUid) {
qmt::MDiagram *diagram = managedModel.m_documentController->modelController()->findObject<qmt::MDiagram>(diagramUid); qmt::MDiagram *diagram = managedModel.m_documentController->modelController()->findObject<qmt::MDiagram>(diagramUid);
QTC_ASSERT(diagram, continue); QMT_ASSERT(diagram, continue);
openDiagram(managedModel.m_documentController, diagram); openDiagram(managedModel.m_documentController, diagram);
return; return;
} }

View File

@@ -135,8 +135,8 @@ void PxNodeController::addExplorerNode(const ProjectExplorer::Node *node,
qmt::DElement *topMostElementAtPos, const QPointF &pos, qmt::DElement *topMostElementAtPos, const QPointF &pos,
qmt::MDiagram *diagram) qmt::MDiagram *diagram)
{ {
QTC_ASSERT(node, return); QMT_ASSERT(node, return);
QTC_ASSERT(diagram, return); QMT_ASSERT(diagram, return);
QString elementName = qmt::NameController::convertFileNameToElementName( QString elementName = qmt::NameController::convertFileNameToElementName(
node->filePath().toString()); node->filePath().toString());
@@ -252,7 +252,7 @@ qmt::MDiagram *PxNodeController::findDiagramForExplorerNode(const ProjectExplore
} }
if (found) { if (found) {
QTC_ASSERT(relativeIndex >= relativeElements.size(), return 0); QMT_ASSERT(relativeIndex >= relativeElements.size(), return 0);
// complete package chain found so check for appropriate diagram within deepest package // complete package chain found so check for appropriate diagram within deepest package
qmt::MDiagram *diagram = d->diagramSceneController->findDiagramBySearchId( qmt::MDiagram *diagram = d->diagramSceneController->findDiagramBySearchId(
package, package->name()); package, package->name());
@@ -329,7 +329,7 @@ void PxNodeController::onMenuActionTriggered(PxNodeController::MenuAction *actio
if (qmt::MObject *existingObject = d->pxnodeUtilities->findSameObject(relativeElements, package)) { if (qmt::MObject *existingObject = d->pxnodeUtilities->findSameObject(relativeElements, package)) {
delete package; delete package;
package = dynamic_cast<qmt::MPackage *>(existingObject); package = dynamic_cast<qmt::MPackage *>(existingObject);
QTC_ASSERT(package, return); QMT_ASSERT(package, return);
d->diagramSceneController->addExistingModelElement(package->uid(), pos, diagram); d->diagramSceneController->addExistingModelElement(package->uid(), pos, diagram);
} else { } else {
qmt::MPackage *requestedRootPackage = d->diagramSceneController->findSuitableParentPackage(topMostElementAtPos, diagram); qmt::MPackage *requestedRootPackage = d->diagramSceneController->findSuitableParentPackage(topMostElementAtPos, diagram);
@@ -367,7 +367,7 @@ void PxNodeController::onMenuActionTriggered(PxNodeController::MenuAction *actio
// if requested and not existing then create new diagram in package // if requested and not existing then create new diagram in package
if (newDiagramInObject) { if (newDiagramInObject) {
auto package = dynamic_cast<qmt::MPackage *>(parentForDiagram); auto package = dynamic_cast<qmt::MPackage *>(parentForDiagram);
QTC_ASSERT(package, return); QMT_ASSERT(package, return);
if (d->diagramSceneController->findDiagramBySearchId(package, newDiagramInObject->name())) if (d->diagramSceneController->findDiagramBySearchId(package, newDiagramInObject->name()))
delete newDiagramInObject; delete newDiagramInObject;
else else

View File

@@ -144,7 +144,7 @@ qmt::MPackage *PxNodeUtilities::createBestMatchingPackagePath(
if (found) if (found)
return package; // complete chain found, innermost package is already the result return package; // complete chain found, innermost package is already the result
QTC_CHECK(!(relativeIndex == maxChainLength && minChainDepth < 0)); QMT_CHECK(!(relativeIndex == maxChainLength && minChainDepth < 0));
if (relativeIndex >= 1 if (relativeIndex >= 1
&& (relativeIndex > maxChainLength && (relativeIndex > maxChainLength
|| (relativeIndex == maxChainLength && depth < minChainDepth))) { || (relativeIndex == maxChainLength && depth < minChainDepth))) {
@@ -154,14 +154,14 @@ qmt::MPackage *PxNodeUtilities::createBestMatchingPackagePath(
} }
} }
QTC_CHECK(maxChainLength < relativeElements.size()); QMT_CHECK(maxChainLength < relativeElements.size());
if (!bestParentPackage) { if (!bestParentPackage) {
QTC_CHECK(maxChainLength == -1); QMT_CHECK(maxChainLength == -1);
QTC_CHECK(minChainDepth == -1); QMT_CHECK(minChainDepth == -1);
maxChainLength = 0; maxChainLength = 0;
bestParentPackage = suggestedParentPackage; bestParentPackage = suggestedParentPackage;
} else { } else {
QTC_CHECK(maxChainLength >= 1); QMT_CHECK(maxChainLength >= 1);
} }
int i = maxChainLength; int i = maxChainLength;
@@ -215,7 +215,7 @@ qmt::MObject *PxNodeUtilities::findSameObject(const QStringList &relativeElement
} }
if (found) { if (found) {
QTC_CHECK(relativeIndex >= relativeElements.size()); QMT_CHECK(relativeIndex >= relativeElements.size());
// chain was found so check for given object within deepest package // chain was found so check for given object within deepest package
QString objectSearchId = qmt::NameController::calcElementNameSearchId(object->name()); QString objectSearchId = qmt::NameController::calcElementNameSearchId(object->name());
foreach (const qmt::Handle<qmt::MObject> &handle, package->children()) { foreach (const qmt::Handle<qmt::MObject> &handle, package->children()) {