Commit 05f7b92f authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Introduce QMT_ASSERT

This change shall solve a lot of Coverity findings

Change-Id: I1e699f7363426e9b6008fc77d3f498fe3d968b4f
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent 8ccdbe19
......@@ -57,10 +57,10 @@ void StringTextSource::setSourceId(int sourceId)
SourceChar StringTextSource::readNextChar()
{
QMT_CHECK(m_sourceId >= 0);
QMT_CHECK(m_index >= 0);
QMT_CHECK(m_lineNumber >= 0);
QMT_CHECK(m_columnNumber >= 0);
QMT_ASSERT(m_sourceId >= 0, return SourceChar());
QMT_ASSERT(m_index >= 0, return SourceChar());
QMT_ASSERT(m_lineNumber >= 0, return SourceChar());
QMT_ASSERT(m_columnNumber >= 0, return SourceChar());
if (m_index >= m_text.length())
return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber));
......
......@@ -66,7 +66,7 @@ void DFactory::visitMElement(const MElement *element)
void DFactory::visitMObject(const MObject *object)
{
auto diagramObject = dynamic_cast<DObject *>(m_product);
QMT_CHECK(diagramObject);
QMT_ASSERT(diagramObject, return);
diagramObject->setModelUid(object->uid());
visitMElement(object);
}
......@@ -120,7 +120,7 @@ void DFactory::visitMItem(const MItem *item)
void DFactory::visitMRelation(const MRelation *relation)
{
auto diagramRelation = dynamic_cast<DRelation *>(m_product);
QMT_CHECK(diagramRelation);
QMT_ASSERT(diagramRelation, return);
diagramRelation->setModelUid(relation->uid());
visitMElement(relation);
}
......
......@@ -59,7 +59,7 @@ void DFlatAssignmentVisitor::visitDObject(const DObject *object)
{
visitDElement(object);
auto target = dynamic_cast<DObject *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setStereotypes(object->stereotypes());
target->setName(object->name());
target->setPos(object->pos());
......@@ -81,7 +81,7 @@ void DFlatAssignmentVisitor::visitDClass(const DClass *klass)
{
visitDObject(klass);
auto target = dynamic_cast<DClass *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setUmlNamespace(klass->umlNamespace());
target->setTemplateParameters(klass->templateParameters());
target->setTemplateDisplay(klass->templateDisplay());
......@@ -94,7 +94,7 @@ void DFlatAssignmentVisitor::visitDComponent(const DComponent *component)
{
visitDObject(component);
auto target = dynamic_cast<DComponent *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setPlainShape(component->isPlainShape());
}
......@@ -107,7 +107,7 @@ void DFlatAssignmentVisitor::visitDItem(const DItem *item)
{
visitDObject(item);
auto target = dynamic_cast<DItem *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setVariety(target->variety());
target->setShapeEditable(target->isShapeEditable());
target->setShape(target->shape());
......@@ -117,7 +117,7 @@ void DFlatAssignmentVisitor::visitDRelation(const DRelation *relation)
{
visitDElement(relation);
auto target = dynamic_cast<DRelation *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setStereotypes(relation->stereotypes());
target->setIntermediatePoints(relation->intermediatePoints());
}
......@@ -131,7 +131,7 @@ void DFlatAssignmentVisitor::visitDDependency(const DDependency *dependency)
{
visitDRelation(dependency);
auto target = dynamic_cast<DDependency *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setDirection(dependency->direction());
}
......@@ -139,7 +139,7 @@ void DFlatAssignmentVisitor::visitDAssociation(const DAssociation *association)
{
visitDRelation(association);
auto target = dynamic_cast<DAssociation *>(m_target);
QMT_CHECK(target);
QMT_ASSERT(target, return);
target->setEndA(association->endA());
target->setEndB(association->endB());
}
......
......@@ -151,7 +151,7 @@ private:
MDiagram *diagram = this->diagram();
foreach (DElement *clonedElement, m_clonedElements) {
DElement *activeElement = diagramController->findElement(clonedElement->uid(), diagram);
QMT_CHECK(activeElement);
QMT_ASSERT(activeElement, return);
int row = diagram->diagramElements().indexOf(activeElement);
emit diagramController->beginUpdateElement(row, diagram);
// clone active element
......@@ -198,9 +198,9 @@ protected:
Clone &clone = m_clonedElements[i];
QMT_CHECK(!clone.m_clonedElement);
DElement *activeElement = diagramController->findElement(clone.m_elementKey, diagram);
QMT_CHECK(activeElement);
QMT_ASSERT(activeElement, return);
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);
DCloneDeepVisitor cloneVisitor;
activeElement->accept(&cloneVisitor);
......@@ -221,7 +221,7 @@ protected:
bool inserted = false;
for (int i = m_clonedElements.count() - 1; i >= 0; --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);
emit diagramController->beginInsertElement(clone.m_indexOfElement, diagram);
diagram->insertDiagramElement(clone.m_indexOfElement, clone.m_clonedElement);
......@@ -287,7 +287,7 @@ public:
DCloneDeepVisitor visitor;
element->accept(&visitor);
clone.m_clonedElement = visitor.cloned();
QMT_CHECK(clone.m_clonedElement);
QMT_ASSERT(clone.m_clonedElement, return);
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
{
QMT_CHECK(diagram);
QMT_ASSERT(diagram, return nullptr);
return diagram->findDiagramElement(key);
}
......@@ -476,7 +476,7 @@ DContainer DiagramController::cutElements(const DSelection &diagramSelection, MD
DContainer DiagramController::copyElements(const DSelection &diagramSelection, const MDiagram *diagram)
{
QMT_CHECK(diagram);
QMT_ASSERT(diagram, return DContainer());
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
DContainer copiedElements;
......@@ -491,7 +491,7 @@ DContainer DiagramController::copyElements(const DSelection &diagramSelection, c
void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagram *diagram)
{
QMT_CHECK(diagram);
QMT_ASSERT(diagram, return);
// clone all elements and renew their keys
QHash<Uid, Uid> renewedKeys;
......@@ -593,7 +593,7 @@ void DiagramController::onBeginUpdateObject(int row, const MObject *parent)
void DiagramController::onEndUpdateObject(int row, const MObject *parent)
{
MObject *modelObject = m_modelController->object(row, parent);
QMT_CHECK(modelObject);
QMT_ASSERT(modelObject, return);
auto modelPackage = dynamic_cast<MPackage *>(modelObject);
foreach (MDiagram *diagram, m_allDiagrams) {
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)
{
QMT_CHECK(owner);
QMT_ASSERT(owner, return);
MObject *modelObject = m_modelController->object(row, owner);
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)
{
QMT_CHECK(parent);
QMT_ASSERT(parent, return);
MObject *modelObject = m_modelController->object(row, parent);
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
MObject *modelObject = m_modelController->object(row, owner);
QMT_CHECK(modelObject);
QMT_ASSERT(modelObject, return);
auto modelDiagram = dynamic_cast<MDiagram *>(modelObject);
if (modelDiagram) {
emit beginResetDiagram(modelDiagram);
......@@ -691,7 +691,7 @@ void DiagramController::onEndUpdateRelation(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);
removeRelations(modelRelation);
......@@ -719,7 +719,7 @@ void DiagramController::onEndMoveRelation(int row, const MObject *owner)
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram,
const QString &commandLabel)
{
QMT_CHECK(diagram);
QMT_ASSERT(diagram, return);
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
if (simplifiedSelection.elements().isEmpty())
......@@ -818,7 +818,7 @@ void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys)
{
QMT_CHECK(renewedKeys);
QMT_ASSERT(renewedKeys, return);
if (element) {
DElement *existingElementOnDiagram = findElementOnAnyDiagram(element->uid());
......@@ -850,7 +850,7 @@ void DiagramController::updateElementFromModel(DElement *element, const MDiagram
DUpdateVisitor visitor(element, diagram);
MElement *melement = m_modelController->findElement(element->modelUid());
QMT_CHECK(melement);
QMT_ASSERT(melement, return);
if (emitUpdateSignal) {
visitor.setCheckNeedsUpdate(true);
......@@ -925,7 +925,7 @@ void DiagramController::verifyDiagramsIntegrity()
FindDiagramsVisitor visitor(&allDiagrams);
m_modelController->rootPackage()->accept(&visitor);
}
QMT_CHECK(allDiagrams == m_allDiagrams);
QMT_ASSERT(allDiagrams == m_allDiagrams, return);
foreach (const MDiagram *diagram, allDiagrams)
verifyDiagramIntegrity(diagram);
}
......@@ -937,8 +937,8 @@ void DiagramController::verifyDiagramIntegrity(const MDiagram *diagram)
foreach (const DElement *delement, diagram->diagramElements()) {
delementsMap.insert(delement->uid(), delement);
if (dynamic_cast<const DObject *>(delement) != 0 || dynamic_cast<const DRelation *>(delement) != 0) {
QMT_CHECK(delement->modelUid().isValid());
QMT_CHECK(m_modelController->findElement(delement->modelUid()) != 0);
QMT_ASSERT(delement->modelUid().isValid(), return);
QMT_ASSERT(m_modelController->findElement(delement->modelUid()) != 0, return);
if (!delement->modelUid().isValid() || m_modelController->findElement(delement->modelUid()) == 0) {
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.";
......@@ -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.";
}
} else {
QMT_CHECK(!delement->modelUid().isValid());
QMT_ASSERT(!delement->modelUid().isValid(), return);
}
}
foreach (const DElement *delement, diagram->diagramElements()) {
if (const DRelation *drelation = dynamic_cast<const DRelation *>(delement)) {
QMT_CHECK(drelation->endAUid().isValid());
QMT_CHECK(delementsMap.contains(drelation->endAUid()));
QMT_ASSERT(drelation->endAUid().isValid(), return);
QMT_ASSERT(delementsMap.contains(drelation->endAUid()), return);
if (!drelation->endAUid().isValid() || !delementsMap.contains(drelation->endAUid()))
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end A.";
QMT_CHECK(drelation->endBUid().isValid());
QMT_CHECK(delementsMap.contains(drelation->endBUid()));
QMT_ASSERT(drelation->endBUid().isValid(), return);
QMT_ASSERT(delementsMap.contains(drelation->endBUid()), return);
if (!drelation->endBUid().isValid() || !delementsMap.contains(drelation->endBUid()))
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end B.";
}
......
......@@ -72,7 +72,7 @@ void DUpdateVisitor::visitMElement(const MElement *element)
void DUpdateVisitor::visitMObject(const MObject *object)
{
auto dobject = dynamic_cast<DObject *>(m_target);
QMT_CHECK(dobject);
QMT_ASSERT(dobject, return);
if (isUpdating(object->stereotypes() != dobject->stereotypes()))
dobject->setStereotypes(object->stereotypes());
const MObject *objectOwner = object->owner();
......@@ -107,7 +107,7 @@ void DUpdateVisitor::visitMPackage(const MPackage *package)
void DUpdateVisitor::visitMClass(const MClass *klass)
{
auto dclass = dynamic_cast<DClass *>(m_target);
QMT_CHECK(dclass);
QMT_ASSERT(dclass, return);
if (isUpdating(klass->umlNamespace() != dclass->umlNamespace()))
dclass->setUmlNamespace(klass->umlNamespace());
if (isUpdating(klass->templateParameters() != dclass->templateParameters()))
......@@ -135,7 +135,7 @@ void DUpdateVisitor::visitMCanvasDiagram(const MCanvasDiagram *diagram)
void DUpdateVisitor::visitMItem(const MItem *item)
{
auto ditem = dynamic_cast<DItem *>(m_target);
QMT_CHECK(ditem);
QMT_ASSERT(ditem, return);
if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable()))
ditem->setShapeEditable(item->isShapeEditable());
if (isUpdating(item->variety() != ditem->variety()))
......@@ -146,7 +146,7 @@ void DUpdateVisitor::visitMItem(const MItem *item)
void DUpdateVisitor::visitMRelation(const MRelation *relation)
{
auto drelation = dynamic_cast<DRelation *>(m_target);
QMT_CHECK(drelation);
QMT_ASSERT(drelation, return);
if (isUpdating(relation->stereotypes() != drelation->stereotypes()))
drelation->setStereotypes(relation->stereotypes());
if (isUpdating(relation->name() != drelation->name()))
......@@ -190,7 +190,7 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
void DUpdateVisitor::visitMDependency(const MDependency *dependency)
{
auto ddependency = dynamic_cast<DDependency *>(m_target);
QMT_CHECK(ddependency);
QMT_ASSERT(ddependency, return);
if (isUpdating(dependency->direction() != ddependency->direction()))
ddependency->setDirection(dependency->direction());
visitMRelation(dependency);
......@@ -204,7 +204,7 @@ void DUpdateVisitor::visitMInheritance(const MInheritance *inheritance)
void DUpdateVisitor::visitMAssociation(const MAssociation *association)
{
auto dassociation = dynamic_cast<DAssociation *>(m_target);
QMT_CHECK(dassociation);
QMT_ASSERT(dassociation, return);
DAssociationEnd endA;
endA.setName(association->endA().name());
endA.setCardinatlity(association->endA().cardinality());
......
......@@ -211,7 +211,7 @@ DSelection DiagramSceneModel::selectedElements() const
DSelection selection;
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
DElement *element = m_itemToElementMap.value(item);
QMT_CHECK(element);
QMT_ASSERT(element, return selection);
selection.append(element->uid(), m_diagram->uid());
}
return selection;
......@@ -569,8 +569,6 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
}
}
break;
default:
QMT_CHECK(false);
}
return collidingItems;
}
......@@ -649,7 +647,7 @@ void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *e
if (newOwner) {
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
DElement *element = m_itemToElementMap.value(item);
QMT_CHECK(element);
QMT_ASSERT(element, return);
if (element->modelUid().isValid()) {
MObject *modelObject = modelController->findObject(element->modelUid());
if (modelObject) {
......@@ -805,15 +803,15 @@ void DiagramSceneModel::onSelectionChanged()
auto relation = dynamic_cast<DRelation *>(element);
if (relation) {
QGraphicsItem *relationItem = m_elementToItemMap.value(relation);
QMT_CHECK(relationItem);
QMT_ASSERT(relationItem, return);
DObject *endAObject = m_diagramController->findElement<DObject>(relation->endAUid(), m_diagram);
QMT_CHECK(endAObject);
QMT_ASSERT(endAObject, return);
QGraphicsItem *endAItem = m_elementToItemMap.value(endAObject);
QMT_CHECK(endAItem);
QMT_ASSERT(endAItem, return);
DObject *endBObject = m_diagramController->findElement<DObject>(relation->endBUid(), m_diagram);
QMT_CHECK(endBObject);
QMT_ASSERT(endBObject, return);
QGraphicsItem *endBItem = m_elementToItemMap.value(endBObject);
QMT_CHECK(endBItem);
QMT_ASSERT(endBItem, return);
if (relationItem && !relationItem->isSelected()
&& (m_selectedItems.contains(endAItem) || newSecondarySelectedItems.contains(endAItem))
&& (m_selectedItems.contains(endBItem) || newSecondarySelectedItems.contains(endBItem))) {
......@@ -826,7 +824,7 @@ void DiagramSceneModel::onSelectionChanged()
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
if (!newSecondarySelectedItems.contains(item)) {
auto selectable = dynamic_cast<ISelectable *>(item);
QMT_CHECK(selectable);
QMT_ASSERT(selectable, return);
selectable->setSecondarySelected(false);
selectionChanged = true;
}
......@@ -834,7 +832,7 @@ void DiagramSceneModel::onSelectionChanged()
foreach (QGraphicsItem *item, newSecondarySelectedItems) {
if (!m_secondarySelectedItems.contains(item)) {
auto selectable = dynamic_cast<ISelectable *>(item);
QMT_CHECK(selectable);
QMT_ASSERT(selectable, return);
selectable->setSecondarySelected(true);
selectionChanged = true;
}
......@@ -877,7 +875,7 @@ void DiagramSceneModel::addExtraSceneItems()
QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element)
{
QMT_CHECK(element);
QMT_ASSERT(element, return nullptr);
QMT_CHECK(!m_elementToItemMap.contains(element));
CreationVisitor visitor(this);
......@@ -891,8 +889,8 @@ QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element)
void DiagramSceneModel::updateGraphicsItem(QGraphicsItem *item, DElement *element)
{
QMT_CHECK(item);
QMT_CHECK(element);
QMT_ASSERT(item, return);
QMT_ASSERT(element, return);
UpdateVisitor visitor(item, this);
element->accept(&visitor);
......@@ -945,8 +943,8 @@ void DiagramSceneModel::unsetFocusItem()
bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem)
{
QMT_CHECK(frontItem);
QMT_CHECK(backItem);
QMT_ASSERT(frontItem, return false);
QMT_ASSERT(backItem, return false);
// shortcut for usual case of root items
if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) {
......
......@@ -165,11 +165,11 @@ void DiagramSceneModel::UpdateVisitor::visitDObject(DObject *object)
void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
{
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) {
PackageItem *packageItem = qgraphicsitem_cast<PackageItem *>(m_graphicsItem);
QMT_CHECK(packageItem);
QMT_ASSERT(packageItem, return);
QMT_CHECK(packageItem->object() == package);
packageItem->update();
}
......@@ -179,11 +179,11 @@ void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
{
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) {
ClassItem *classItem = qgraphicsitem_cast<ClassItem *>(m_graphicsItem);
QMT_CHECK(classItem);
QMT_ASSERT(classItem, return);
QMT_CHECK(classItem->object() == klass);
classItem->update();
}
......@@ -193,11 +193,11 @@ void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
{
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) {
ComponentItem *componentItem = qgraphicsitem_cast<ComponentItem *>(m_graphicsItem);
QMT_CHECK(componentItem);
QMT_ASSERT(componentItem, return);
QMT_CHECK(componentItem->object() == component);
componentItem->update();
}
......@@ -207,11 +207,11 @@ void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
{
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) {
DiagramItem *documentItem = qgraphicsitem_cast<DiagramItem *>(m_graphicsItem);
QMT_CHECK(documentItem);
QMT_ASSERT(documentItem, return);
QMT_CHECK(documentItem->object() == diagram);
documentItem->update();
}
......@@ -221,11 +221,11 @@ void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
{
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0) {
ItemItem *itemItem = qgraphicsitem_cast<ItemItem *>(m_graphicsItem);
QMT_CHECK(itemItem);
QMT_ASSERT(itemItem, return);
QMT_CHECK(itemItem->object() == item);
itemItem->update();
}
......@@ -235,13 +235,13 @@ void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
void DiagramSceneModel::UpdateVisitor::visitDRelation(DRelation *relation)
{
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
if (m_relatedElement == 0
|| m_relatedElement->uid() == relation->endAUid()
|| m_relatedElement->uid() == relation->endBUid()) {
RelationItem *relationItem = qgraphicsitem_cast<RelationItem *>(m_graphicsItem);
QMT_CHECK(relationItem);
QMT_ASSERT(relationItem, return);
QMT_CHECK(relationItem->relation() == relation);
relationItem->update();
}
......@@ -265,10 +265,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAssociation(DAssociation *associati
void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
{
Q_UNUSED(annotation); // avoid warning in release mode
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
AnnotationItem *annotationItem = qgraphicsitem_cast<AnnotationItem *>(m_graphicsItem);
QMT_CHECK(annotationItem);
QMT_ASSERT(annotationItem, return);
QMT_CHECK(annotationItem->annotation() == annotation);
annotationItem->update();
}
......@@ -276,10 +276,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
{
Q_UNUSED(boundary); // avoid warning in release mode
QMT_CHECK(m_graphicsItem);
QMT_ASSERT(m_graphicsItem, return);
BoundaryItem *boundaryItem = qgraphicsitem_cast<BoundaryItem *>(m_graphicsItem);
QMT_CHECK(boundaryItem);
QMT_ASSERT(boundaryItem, return);
QMT_CHECK(boundaryItem->boundary() == boundary);
boundaryItem->update();
}
......
......@@ -60,7 +60,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QMT_CHECK(option);
QMT_ASSERT(option, return);
QStyleOptionGraphicsItem option2(*option);
option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);
......
......@@ -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->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());
if (!endAItem)
return;
......
......@@ -62,7 +62,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QMT_CHECK(option);
QMT_ASSERT(option, return);
QStyleOptionGraphicsItem option2(*option);
option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);
......
......@@ -82,7 +82,7 @@ void ClassItem::update()
updateStereotypeIconDisplay();
auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass);
QMT_ASSERT(diagramClass, return);
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);
if (baseClass) {
auto derivedClass = dynamic_cast<DClass *>(object());
QMT_CHECK(derivedClass);
QMT_ASSERT(derivedClass, return);
diagramSceneModel()->diagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, diagramSceneModel()->diagram());
}
} 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);
if (assoziatedClass) {
auto derivedClass = dynamic_cast<DClass *>(object());
QMT_CHECK(derivedClass);
QMT_ASSERT(derivedClass, return);
diagramSceneModel()->diagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, diagramSceneModel()->diagram());
}
}
......@@ -316,7 +316,7 @@ bool ClassItem::handleSelectedContextMenuAction(const QString &id)
QString ClassItem::buildDisplayName() const
{
auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass);
QMT_ASSERT(diagramClass, return QString());
QString name;
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
if (NameController::parseClassName(displayName, 0, &name, &templateParameters)) {
auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass);
QMT_ASSERT(diagramClass, return);
ModelController *modelController = diagramSceneModel()->diagramSceneController()->modelController();
MClass *mklass = modelController->findObject<MClass>(diagramClass->modelUid());
if (mklass && (name != mklass->name() || templateParameters != mklass->templateParameters())) {
......@@ -362,7 +362,7 @@ void ClassItem::setFromDisplayName(const QString &displayName)
DClass::TemplateDisplay ClassItem::templateDisplay() const
{
auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass);
QMT_ASSERT(diagramClass, return DClass::TemplateSmart);
DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay();
if (templateDisplay == DClass::TemplateSmart) {
......@@ -560,12 +560,12 @@ void ClassItem::updateMembers(const Style *style)
QString *text = 0;
auto dclass = dynamic_cast<DClass *>(object());
QMT_CHECK(dclass);
QMT_ASSERT(dclass, return);
foreach (const MClassMember &member, dclass->members()) {
switch (member.memberType()) {
case MClassMember::MemberUndefined:
QMT_CHECK(false);
QMT_ASSERT(false, return);
break;
case MClassMember::MemberAttribute:
currentVisibility = &attributesVisibility;
......
......@@ -237,7 +237,7 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos,
bool ComponentItem::hasPlainShape() const
{
auto diagramComponent = dynamic_cast<DComponent *>(object());
QMT_CHECK(diagramComponent);
QMT_ASSERT(diagramComponent, return false);
return diagramComponent->isPlainShape();
}
......
......@@ -71,7 +71,7 @@ void ItemItem::update()
auto diagramItem = dynamic_cast<DItem *>(object());
Q_UNUSED(diagramItem); // avoid warning about unsed variable
QMT_CHECK(diagramItem);
QMT_ASSERT(diagramItem, return);
const Style *style = adaptedStyle(shapeIconId());
......
......@@ -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
QMT_CHECK(object()->modelUid().isValid());
MObject *mobject = m_diagramSceneModel->diagramController()->modelController()->findObject(object()->modelUid());
QMT_CHECK(mobject);
QMT_ASSERT(mobject, return false);
MObject *owner = mobject->owner();