Commit b37eebda authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Fix bug not placing class N1::A below N1 package in tree view.

The problem was, that Import_Utils::createUMLObject() tries to find an object
in different namespaces and only creates an uml object if not found.

In the case of parsing a c++ import class specification we simply need
to create the related uml class object in the current namespace, which
is provided by the additional parameter "doNotSearch".

Related test case is https://bugs.kde.org/show_bug.cgi?id=336810#c10

CCBUG:368810
parent 9ffb8eb8
......@@ -170,7 +170,8 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
const QString& inName,
UMLPackage *parentPkg,
const QString& comment,
const QString& stereotype)
const QString& stereotype,
bool doNotSearch)
{
QString name = inName;
UMLDoc *umldoc = UMLApp::app()->document();
......@@ -206,8 +207,15 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
name = name.mid(2);
parentPkg = logicalView;
}
UMLObject * o = umldoc->findUMLObject(name, type, parentPkg);
bNewUMLObjectWasCreated = false;
UMLObject *o = NULL;
if (!doNotSearch) {
o = umldoc->findUMLObject(name, type, parentPkg);
bNewUMLObjectWasCreated = false;
} else {
o = Object_Factory::createNewUMLObject(type, name, parentPkg);
bNewUMLObjectWasCreated = true;
bPutAtGlobalScope = false;
}
if (o == NULL) {
// Strip possible adornments and look again.
const bool isConst = name.contains(QRegExp("^const "));
......
......@@ -33,7 +33,8 @@ namespace Import_Utils {
const QString& name,
UMLPackage *parentPkg = NULL,
const QString& comment = QString(),
const QString& stereotype = QString());
const QString& stereotype = QString(),
bool doNotSearch = false);
void putAtGlobalScope(bool yesno);
......
......@@ -336,7 +336,7 @@ void CppTree2Uml::parseClassSpecifier(ClassSpecifierAST* ast)
}
UMLObject * o = Import_Utils::createUMLObject(UMLObject::ot_Class, className,
m_currentNamespace[m_nsCnt],
ast->comment());
ast->comment(), QString(), true);
UMLClassifier *klass = static_cast<UMLClassifier*>(o);
flushTemplateParams(klass);
if (ast->baseClause())
......
......@@ -28,6 +28,10 @@ UMLObject* createUMLObject(UMLObject::ObjectType type,
UMLPackage *parentPkg = 0,
bool solicitNewName = true);
UMLObject* createNewUMLObject(UMLObject::ObjectType type,
const QString &n,
UMLPackage *parentPkg);
UMLClassifierListItem* createChildObject(UMLClassifier *parent,
UMLObject::ObjectType type,
const QString& name = QString());
......
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