Commit 706b0874 authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Fix a number of trivial coverity issues

Change-Id: Ie61e017b993ac788284611fb40052e5f59521a56
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent 550ed292
......@@ -117,7 +117,7 @@ StereotypeDefinitionParserError::~StereotypeDefinitionParserError()
class StereotypeDefinitionParser::StereotypeDefinitionParserPrivate
{
public:
TextScanner *m_scanner = 0;
TextScanner *m_scanner = nullptr;
};
......@@ -134,8 +134,8 @@ public:
}
int m_keyword = -1;
ShapeValueF::Unit m_unit;
ShapeValueF::Origin m_origin;
ShapeValueF::Unit m_unit = ShapeValueF::UnitAbsolute;
ShapeValueF::Origin m_origin = ShapeValueF::OriginCenter;
};
StereotypeDefinitionParser::StereotypeDefinitionParser(QObject *parent)
......
......@@ -46,10 +46,6 @@ Token::Token(Token::Type type, int subtype, const QString &text, const SourcePos
{
}
Token::~Token()
{
}
void Token::setType(Token::Type type)
{
m_type = type;
......
......@@ -50,7 +50,6 @@ public:
Token();
Token(Type type, const QString &text, const SourcePos &sourcePos);
Token(Type type, int subtype, const QString &text, const SourcePos &sourcePos);
~Token();
Type type() const { return m_type; }
void setType(Type type);
......
......@@ -154,7 +154,7 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
// TODO improve performance of MDiagram::findDiagramElement
DObject *endAObject = dynamic_cast<DObject *>(m_diagram->findDiagramElement(drelation->endAUid()));
if (!endAObject || relation->endAUid() != endAObject->modelUid()) {
isUpdating(true);
(void) isUpdating(true);
endAObject = 0;
// TODO use DiagramController::findDelegate (and improve performance of that method)
foreach (DElement *diagramElement, m_diagram->diagramElements()) {
......@@ -170,7 +170,7 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
}
DObject *endBObject = dynamic_cast<DObject *>(m_diagram->findDiagramElement(drelation->endBUid()));
if (!endBObject || relation->endBUid() != endBObject->modelUid()) {
isUpdating(true);
(void) isUpdating(true);
endBObject = 0;
// TODO use DiagramController::findDelegate
foreach (DElement *diagramElement, m_diagram->diagramElements()) {
......
......@@ -121,7 +121,7 @@ void StereotypeDisplayVisitor::visitDClass(const DClass *klass)
m_stereotypeIconElement = StereotypeIcon::ElementClass;
MClass *modelKlass = m_modelController->findObject<MClass>(klass->modelUid());
bool hasMembers = false;
if (!modelKlass->members().isEmpty() && klass->showAllMembers())
if (modelKlass && !modelKlass->members().isEmpty() && klass->showAllMembers())
hasMembers = true;
m_stereotypeSmartDisplay = hasMembers ? DObject::StereotypeDecoration : DObject::StereotypeIcon;
visitDObject(klass);
......
......@@ -33,35 +33,6 @@ MClassMember::MClassMember(MemberType memberType)
{
}
MClassMember::MClassMember(const MClassMember &rhs)
: m_uid(rhs.m_uid),
m_stereotypes(rhs.m_stereotypes),
m_group(rhs.m_group),
m_declaration(rhs.m_declaration),
m_visibility(rhs.m_visibility),
m_memberType(rhs.m_memberType),
m_properties(rhs.m_properties)
{
}
MClassMember::~MClassMember()
{
}
MClassMember &MClassMember::operator=(const MClassMember &rhs)
{
if (this != &rhs) {
m_uid = rhs.m_uid;
m_stereotypes = rhs.m_stereotypes;
m_group = rhs.m_group;
m_declaration = rhs.m_declaration;
m_visibility = rhs.m_visibility;
m_memberType = rhs.m_memberType;
m_properties = rhs.m_properties;
}
return *this;
}
void MClassMember::setUid(const Uid &uid)
{
m_uid = uid;
......
......@@ -69,10 +69,6 @@ public:
Q_DECLARE_FLAGS(Properties, Property)
explicit MClassMember(MemberType memberType = MemberUndefined);
MClassMember(const MClassMember &rhs);
~MClassMember();
MClassMember &operator=(const MClassMember &rhs);
Uid uid() const { return m_uid; }
void setUid(const Uid &uid);
......
......@@ -505,9 +505,10 @@ private:
QMT_CHECK(object);
MObject *formerOwner = object->owner();
int formerRow = formerOwner->children().indexOf(object);
MObject *newOwner = m_modelController->findObject(m_ownerKey);
QMT_CHECK(newOwner);
emit m_modelController->beginMoveObject(formerRow, formerOwner);
formerOwner->decontrolChild(object);
MObject *newOwner = m_modelController->findObject(m_ownerKey);
newOwner->insertChild(m_indexOfElement, object);
int newRow = m_indexOfElement;
m_ownerKey = formerOwner->uid();
......@@ -560,9 +561,10 @@ private:
QMT_CHECK(relation);
MObject *formerOwner = relation->owner();
int formerRow = formerOwner->relations().indexOf(relation);
MObject *newOwner = m_modelController->findObject(m_ownerKey);
QMT_CHECK(newOwner);
emit m_modelController->beginMoveRelation(formerRow, formerOwner);
formerOwner->decontrolRelation(relation);
MObject *newOwner = m_modelController->findObject(m_ownerKey);
newOwner->insertRelation(m_indexOfElement, relation);
int newRow = m_indexOfElement;
m_ownerKey = formerOwner->uid();
......
......@@ -55,7 +55,7 @@ private:
void startDelayedSortTimer();
TreeModel *m_treeModel;
TreeModel *m_treeModel = nullptr;
QTimer m_delayedSortTimer;
};
......
......@@ -639,6 +639,7 @@ void PropertiesView::MView::visitMInheritance(const MInheritance *inheritance)
QMT_CHECK(derivedClass);
setEndAName(tr("Derived class: %1").arg(derivedClass->name()));
MObject *baseClass = m_propertiesView->modelController()->findObject(inheritance->base());
QMT_CHECK(baseClass);
setEndBName(tr("Base class: %1").arg(baseClass->name()));
visitMRelation(inheritance);
}
......
......@@ -52,7 +52,7 @@ public:
private:
Uid m_uid;
QString m_fileName;
MPackage *m_rootPackage;
MPackage *m_rootPackage = nullptr;
QString m_configPath;
};
......
......@@ -42,9 +42,11 @@ class QMT_EXPORT IconShape
public:
IconShape();
IconShape(const IconShape &rhs);
IconShape(const IconShape &&) = delete;
~IconShape();
IconShape &operator=(const IconShape &rhs);
IconShape &operator=(const IconShape &&) = delete;
QSizeF size() const;
void setSize(const QSizeF &size);
......
......@@ -27,21 +27,6 @@
namespace qmt {
StereotypeIcon::StereotypeIcon()
: m_width(100.0),
m_height(100.0),
m_minWidth(-1),
m_minHeight(-1),
m_sizeLock(LockNone),
m_display(DisplaySmart),
m_textAlignment(TextalignBelow)
{
}
StereotypeIcon::~StereotypeIcon()
{
}
void StereotypeIcon::setId(const QString &id)
{
m_id = id;
......
......@@ -67,9 +67,6 @@ public:
TextalignNone
};
StereotypeIcon();
~StereotypeIcon();
QString id() const { return m_id; }
void setId(const QString &id);
QString title() const;
......@@ -104,13 +101,13 @@ private:
QString m_title;
QSet<Element> m_elements;
QSet<QString> m_stereotypes;
qreal m_width;
qreal m_height;
qreal m_minWidth;
qreal m_minHeight;
SizeLock m_sizeLock;
Display m_display;
TextAlignment m_textAlignment;
qreal m_width = 100.0;
qreal m_height = 100.0;
qreal m_minWidth = -1;
qreal m_minHeight = -1;
SizeLock m_sizeLock = LockNone;
Display m_display = DisplaySmart;
TextAlignment m_textAlignment = TextalignBelow;
QColor m_baseColor;
IconShape m_iconShape;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment