Bug 137497

Summary: Faulty behavior when a class inside of a package is modified
Product: [Applications] umbrello Reporter: Egbert Voigt <Egbert.Voigt>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Egbert Voigt 2006-11-17 17:30:00 UTC
Version:           1.5.51 (using KDE KDE 3.5.1)
Installed from:    Compiled From Sources
Compiler:          gcc 4.1 
OS:                Linux

Class C is part of package P. Then change something (add a comment) in C.
This leads to an additional package with the name "P.". The next change add a package "P.." and so on.

This patch fix the bug, but it could be not the best decision.

umbrello-1.5.51/umbrello/umlobject.cpp
307a308
>       QString packageName = _name.left(_name.length() - 1); // remove trailing separator, i.e. "."
309c310
<         pkgObj = umldoc->findUMLObject(_name);
---
>         pkgObj = umldoc->findUMLObject(packageName);
312,313c313,314
<                 << _name << " for " << m_Name << endl;
<             pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, _name);
---
>                 << packageName << " for " << m_Name << endl;
>             pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, packageName);
318c319
<                     << "existing " << _name << " is not a container" << endl;
---
>                     << "existing " << packageName << " is not a container" << endl;
321c322
<                 pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, _name);
---
>                 pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, packageName);
Comment 1 Oliver Kellogg 2006-11-17 19:37:42 UTC
SVN commit 605677 by okellogg:

getPackage(): Set separator to language dependent default if empty.
BUG:137497


 M  +2 -1      ChangeLog  
 M  +4 -10     umbrello/umlobject.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #605676:605677
@@ -1,4 +1,4 @@
-Version 1.5.52
+Version 1.5.6
 
 * Fixed segfault in UMLClassifier::checkOperationSignature()
   (http://www.geeksoc.org/~jr/umbrello/uml-devel/9816.html)
@@ -8,6 +8,7 @@
 * Fixed bugs in generated code of various code generators
 * Bugs/wishes from http://bugs.kde.org:
 * Shift + Left and Shift+Right causes SIGSEGV (136288)
+* Faulty behavior when a class inside of a package is modified (137497)
 
 Version 1.5.51
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #605676:605677
@@ -113,17 +113,9 @@
         bool skipPackage = false;
         if (!includeRoot) {
             UMLDoc *umldoc = UMLApp::app()->getDocument();
-            if (m_pUMLPackage == umldoc->getDatatypeFolder()) {
+            if (umldoc->rootFolderType(m_pUMLPackage) != Uml::N_MODELTYPES ||
+                m_pUMLPackage == umldoc->getDatatypeFolder())
                 skipPackage = true;
-            } else {
-                for (int i = 0; i < Uml::N_MODELTYPES; i++) {
-                    const Uml::Model_Type mt = (Uml::Model_Type)i;
-                    if (m_pUMLPackage == umldoc->getRootFolder(mt)) {
-                        skipPackage = true;
-                        break;
-                    }
-                }
-            }
         }
         if (!skipPackage) {
             if (separator.isEmpty())
@@ -344,6 +336,8 @@
 }
 
 QString UMLObject::getPackage(QString separator, bool includeRoot) {
+    if (separator.isEmpty())
+        separator = UMLApp::app()->activeLanguageScopeSeparator();
     QString fqn = getFullyQualifiedName(separator, includeRoot);
     if (!fqn.contains(separator))
         return "";