Bug 93298 - code import sometimes prompts for a new datatype name
Summary: code import sometimes prompts for a new datatype name
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-15 01:46 UTC by Jonathan Riddell
Modified: 2005-01-31 19:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Riddell 2004-11-15 01:46:45 UTC
Version:            (using KDE Devel)

When performing code import on some files Umbrello brings up a dialogue asking for a name for a new datatype.  Not sure what causes this yet but an example file is
kdepim/libkcal/calendarlocal.h in KDE's CVS.
Comment 1 Oliver Kellogg 2004-11-18 08:16:17 UTC
*** Bug has been marked as fixed ***.
Comment 2 Oliver Kellogg 2004-11-20 10:38:56 UTC
Most occurrences of this problem are fixed, but one persists:
While the processing of include files is not yet functioning,
defining scopes is a big problem.
Take for example the following file:

 // test.h  - demonstrates the problem with scope synthesis
 #include <othertype.h>   // include files are not currently parsed
 namespace MyNS {
   class Test {
     Othertype str;
   };
 }
 // end of file

Now, where should the UML object for Othertype be created?
At the global level, or inside MyNS - we have no way of knowing.
othertype.h may look like this:

 // othertype.h
 namespace MyNS {
   class Othertype {
   };
 }
Comment 3 Oliver Kellogg 2005-01-10 22:56:00 UTC
CVS commit by okellogg: 

BUG:93298 - included files are now imported (if they can be found)


  M +3 -2      ChangeLog   1.58


--- kdesdk/umbrello/ChangeLog  #1.57:1.58
@@ -22,6 +22,7 @@
 89582 89699 89860 89903       90102 90106 90206 90755 91298
 91433 91434 91494 91869 91922 92116 92123 92222 92300 92301
-92781 92995 93122 93219 93297 93501 93595 93696 94173 94728
-94795 94883 95082 95252 95722 95924 95951 95954 96216 96221
+92781 92995 93122 93219 93297 93298 93501 93595 93696 94173
+94728 94795 94883 95082 95252 95722 95924 95951 95954 96216
+96221
 
 Version 1.3


Comment 4 Oliver Kellogg 2005-01-16 14:27:50 UTC
The problem still occurs with anonymous types, for example

class LaClasse {
public:
  struct {
    int _a;
    bool _b;
  } _anonymous;
};

Workaround: Give the type a name.
Comment 5 Oliver Kellogg 2005-01-31 19:38:49 UTC
CVS commit by okellogg: 

Put scope qualified datatypes in the global scope.
This removes another occasion of gratuitous prompting for a type name.
CCBUG:93298


  M +3 -6      classimport.cpp   1.67
  M +15 -1     model_utils.cpp   1.19


--- kdesdk/umbrello/umbrello/classimport.cpp  #1.66:1.67
@@ -116,5 +116,6 @@ UMLObject *ClassImport::createUMLObject(
                                         parentPkg = static_cast<UMLPackage*>(o);
                                 }
-                                name.remove(QRegExp("^.*::"));  // may also zap "const "
+                                // All scope qualified datatypes live in the global scope.
+                                m_putAtGlobalScope = true;
                         }
                         Uml::Object_Type t = type;
@@ -125,13 +126,9 @@ UMLObject *ClassImport::createUMLObject(
                 if (isConst || isPointer || isRef) {
                         // Create the full given type (including adornments.)
-                        if (isPointer || isRef) {
-                                type = Uml::ot_Datatype;
-                        } else if (type == Uml::ot_UMLObject)
-                                type = Uml::ot_Class;
                         if (isConst)
                                 name.prepend("const ");
                         if (m_putAtGlobalScope)
                                 parentPkg = NULL;
-                        o = m_umldoc->createUMLObject(type, name, parentPkg);
+                        o = m_umldoc->createUMLObject(Uml::ot_Datatype, name);
                         UMLDatatype *dt = static_cast<UMLDatatype*>(o);
                         UMLClassifier *c = dynamic_cast<UMLClassifier*>(origType);

--- kdesdk/umbrello/umbrello/model_utils.cpp  #1.18:1.19
@@ -98,7 +98,21 @@ UMLObject* findUMLObject(UMLObjectList i
                          Uml::Object_Type type /* = ot_UMLObject */,
                          UMLObject *currentObj /* = NULL */) {
-        QStringList components = QStringList::split("::", name);
+        QStringList components;
+        if (name.contains("::"))
+                components = QStringList::split("::", name);
+        else if (name.contains("."))
+                components = QStringList::split(".", name);
         QString nameWithoutFirstPrefix;
         if (components.size() > 1) {
+                if (name.contains(QRegExp("[^\\w:\\.]"))) {
+                        // It's obviously a datatype.
+                        // Scope qualified datatypes live in the global scope.
+                        for (UMLObjectListIt oit(inList); oit.current(); ++oit) {
+                                UMLObject *obj = oit.current();
+                                if (obj->getName() == name)
+                                        return obj;
+                        }
+                        return NULL;
+                }
                 name = components.front();
                 components.pop_front();