[Uml-devel] KDE/kdesdk/umbrello/umbrello

Sharan Rao sharanrao at gmail.com
Sat Aug 4 20:24:24 UTC 2007


SVN commit 696437 by sharan:

Check duplicates in packages only for objects which are not association types.

The code in UMLPackage::addObject() is a possible solution to Bug#142788 ( and BUG#138964 )
One refinement necessary is to enable cancelling the input of a new name, and thus cancel the operation.
But as the return value of this function is hardly checked anywhere in umbrello code, this would eventually lead to
duplicates again :(. Hence, one *has* to enter a new unique name and complete the operation.



 M  +14 -12    package.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/package.cpp #696436:696437
@@ -121,25 +121,27 @@
             }
             addAssocToConcepts(assoc);
         }
-    }
-    QString name = pObject->getName();
-    QString oldName = name;
-    while ( findObject( name ) != NULL  ) {
-       name = Model_Utils::uniqObjectName(pObject->getBaseType(),this);
-       bool ok = true;
-       name = KInputDialog::getText(i18n("Name"), i18n("An object with this name already exists in the package %1.<br /> Please enter a new name:", this->getName()), name, &ok, (QWidget*)UMLApp::app());
-        if (!ok) {
+    } else {
+
+      QString name = pObject->getName();
+      QString oldName = name;
+      while ( findObject( name ) != NULL  ) {
+         name = Model_Utils::uniqObjectName(pObject->getBaseType(),this);
+         bool ok = true;
+         name = KInputDialog::getText(i18n("Name"), i18n("An object with this name already exists in the package %1.<br /> Please enter a new name:", this->getName()), name, &ok, (QWidget*)UMLApp::app());
+         if (!ok) {
             name = oldName;
             continue;
-        }
-        if (name.length() == 0) {
+         }
+         if (name.length() == 0) {
             KMessageBox::error(0, i18n("That is an invalid name."),
                                i18n("Invalid Name"));
             continue;
         }
-    }
-    if ( oldName != name ) {
+      }
+      if ( oldName != name ) {
         pObject->setName(name);
+      }
     }
     m_objects.append( pObject );
     return true;




More information about the umbrello-devel mailing list