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

Andi Fischer andi.fischer at hispeed.ch
Mon May 25 21:45:15 UTC 2009


SVN commit 972879 by fischer:

Some Kryzy complaints about crashy code (check 5)fixed.

 M  +16 -9     classifier.cpp  
 M  +13 -9     dialogs/codeeditor.cpp  
 M  +6 -4      dialogs/pkgcontentspage.cpp  
 M  +29 -31    dialogs/umloperationdialog.cpp  
 M  +11 -7     uml.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/classifier.cpp #972878:972879
@@ -9,7 +9,7 @@
  ***************************************************************************/
 #include "classifier.h"
 
-// qt/kde includes
+// kde includes
 #include <kdebug.h>
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -38,6 +38,9 @@
 #include "optionstate.h"
 #include "icon_utils.h"
 
+// qt includes
+#include <QtCore/QPointer>
+
 using namespace Uml;
 
 /**
@@ -47,7 +50,7 @@
  * @param id     The unique id of the Concept.
  */
 UMLClassifier::UMLClassifier(const QString & name, Uml::IDType id)
-        : UMLPackage(name, id)
+  : UMLPackage(name, id)
 {
     m_BaseType = Uml::ot_Class;  // default value
     m_pClassAssoc = NULL;
@@ -255,9 +258,10 @@
         if (nameNotSet)
             op->setName( uniqChildName(Uml::ot_Operation) );
         while (true) {
-            UMLOperationDialog operationDialogue(0, op);
-            if( operationDialogue.exec() != KDialog::Accepted ) {
+            QPointer<UMLOperationDialog> operationDialog = new UMLOperationDialog(0, op);
+            if( operationDialog->exec() != KDialog::Accepted ) {
                 delete op;
+                delete operationDialog;
                 return NULL;
             } else if (checkOperationSignature(op->getName(), op->getParmList())) {
                 KMessageBox::information(0,
@@ -265,6 +269,7 @@
             } else {
                 break;
             }
+            delete operationDialog;
         }
     }
 
@@ -381,9 +386,9 @@
 
     int button = KDialog::Accepted;
 
-    while (button==KDialog::Accepted && !goodName) {
-        UMLTemplateDialog templateDialogue(0, newTemplate);
-        button = templateDialogue.exec();
+    while (button == KDialog::Accepted && !goodName) {
+        QPointer<UMLTemplateDialog> templateDialog = new UMLTemplateDialog(0, newTemplate);
+        button = templateDialog->exec();
         name = newTemplate->getName();
 
         if (name.length() == 0) {
@@ -395,6 +400,7 @@
         else {
             goodName = true;
         }
+        delete templateDialog;
     }
 
     if (button != KDialog::Accepted) {
@@ -758,8 +764,8 @@
     //check for name.isNull() stops dialog being shown
     //when creating attribute via list view
     while (button == KDialog::Accepted && !goodName && name.isNull()) {
-        UMLAttributeDialog attributeDialogue(0, newAttribute);
-        button = attributeDialogue.exec();
+        QPointer<UMLAttributeDialog> attributeDialog = new UMLAttributeDialog(0, newAttribute);
+        button = attributeDialog->exec();
         QString name = newAttribute->getName();
 
         if(name.length() == 0) {
@@ -769,6 +775,7 @@
         } else {
             goodName = true;
         }
+        delete attributeDialog;
     }
 
     if (button != KDialog::Accepted) {
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/codeeditor.cpp #972878:972879
@@ -5,7 +5,7 @@
  *   (at your option) any later version.                                   *
  *                                                                         *
  *   copyright (C) 2003  Brian Thomas  <brian.thomas at gsfc.nasa.gov>        *
- *   copyright (C) 2004-2008                                               *
+ *   copyright (C) 2004-2009                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -21,6 +21,7 @@
 #include <QtGui/QLabel>
 #include <QtGui/QBrush>
 #include <QtGui/QLayout>
+#include <QtCore/QPointer>
 #include <QtCore/QRegExp>
 
 // kde includes
@@ -53,13 +54,13 @@
 
 CodeEditor::CodeEditor (const QString & text, const QString & context, CodeViewerDialog * parent,
     const char * name, CodeDocument * doc)
-        : Q3TextEdit (text, context, parent, name)
+  : Q3TextEdit (text, context, parent, name)
 {
     init(parent, doc);
 }
 
 CodeEditor::CodeEditor (CodeViewerDialog * parent, const char* name, CodeDocument * doc)
-        : Q3TextEdit (parent, name)
+  : Q3TextEdit (parent, name)
 {
     init(parent, doc);
 }
@@ -149,10 +150,11 @@
 
                 if ( (at = dynamic_cast<UMLAttribute*>(obj)) )
                 {
-                    UMLAttributeDialog dlg( this, at);
-                    if ( dlg.exec() ) {
+                    QPointer<UMLAttributeDialog> dlg = new UMLAttributeDialog( this, at);
+                    if ( dlg->exec() == KDialog::Accepted ) {
                         rebuildView(para);
                     }
+                    delete dlg;
                 }
                 else if ( (dynamic_cast<UMLClassifier*>(obj)) )
                 {
@@ -162,18 +164,20 @@
                 }
                 else if ( (role = dynamic_cast<UMLRole*>(obj)))
                 {
-                    UMLRoleDialog dlg(this,role);
-                    if ( dlg.exec() ) {
+                    QPointer<UMLRoleDialog> dlg = new UMLRoleDialog(this, role);
+                    if ( dlg->exec() == KDialog::Accepted ) {
                         rebuildView(para);
                     }
+                    delete dlg;
                 }
                 else if ( (op = dynamic_cast<UMLOperation*>(obj)) )
                     //else if( (cop = dynamic_cast<CodeOperation*>(tBlock)) )
                 {
-                    UMLOperationDialog dlg(this,op);
-                    if ( dlg.exec() ) {
+                    QPointer<UMLOperationDialog> dlg = new UMLOperationDialog(this, op);
+                    if ( dlg->exec() == KDialog::Accepted ) {
                         rebuildView(para);
                     }
+                    delete dlg;
                 }
                 else
                 {
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/pkgcontentspage.cpp #972878:972879
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2003-2008                                               *
+ *   copyright (C) 2003-2009                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -18,6 +18,7 @@
 #include <klocale.h>
 #include <kdebug.h>
 
+#include <QtCore/QPointer>
 #include <QtGui/QLayout>
 #include <QtGui/QHBoxLayout>
 
@@ -28,7 +29,7 @@
  * @param pkg       The UMLPackage being represented.
  */
 PkgContentsPage::PkgContentsPage(QWidget *parent, UMLPackage *pkg)
-        : QWidget(parent)
+  : QWidget(parent)
 {
     m_package = pkg;
     int margin = fontMetrics().height();
@@ -78,8 +79,9 @@
     }
     UMLObjectList contents = m_package->containedObjects();
     UMLObject *o = contents.at(index);
-    ClassPropDlg dlg(this, o, true);
-    dlg.exec();
+    QPointer<ClassPropDlg> dlg = new ClassPropDlg(this, o, true);
+    dlg->exec();
+    delete dlg;
 }
 
 /**
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umloperationdialog.cpp #972878:972879
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2002-2008                                               *
+ *   copyright (C) 2002-2009                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -36,6 +36,7 @@
 #include <karrowbutton.h>
 
 //qt includes
+#include <QtCore/QPointer>
 #include <QtGui/QLayout>
 #include <QtGui/QGroupBox>
 #include <QtGui/QListWidget>
@@ -48,7 +49,7 @@
 #include <QtGui/QGridLayout>
 
 UMLOperationDialog::UMLOperationDialog( QWidget * parent, UMLOperation * pOperation )
-        : KDialog( parent)
+  : KDialog( parent)
 {
     setCaption( i18n("Operation Properties") );
     setButtons( Help | Ok | Cancel );
@@ -185,25 +186,25 @@
     }
 
     // set scope
-    switch (m_operation -> getVisibility()) {
+    switch (m_operation->getVisibility()) {
     case Uml::Visibility::Public:
-        m_pPublicRB -> setChecked( true );
+        m_pPublicRB->setChecked( true );
         break;
     case Uml::Visibility::Private:
-        m_pPrivateRB -> setChecked( true );
+        m_pPrivateRB->setChecked( true );
         break;
     case Uml::Visibility::Protected:
-        m_pProtectedRB -> setChecked( true );
+        m_pProtectedRB->setChecked( true );
         break;
     case Uml::Visibility::Implementation:
-        m_pImplementationRB -> setChecked( true );
+        m_pImplementationRB->setChecked( true );
         break;
     default:
         break;
     }
 
     // manage stereotypes
-    m_pStereoTypeCB -> setDuplicatesEnabled(false); // only allow one of each type in box
+    m_pStereoTypeCB->setDuplicatesEnabled(false); // only allow one of each type in box
     m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
     insertStereotypesSorted(m_operation->getStereotype());
 
@@ -240,7 +241,7 @@
         type = ListPopupMenu::mt_New_Parameter;
     }
     if (m_menu) {
-        m_menu -> hide();
+        m_menu->hide();
         disconnect(m_menu, SIGNAL(triggered(QAction*)), this, SLOT(slotParmPopupMenuSel(QAction*)));
         delete m_menu;
         m_menu = 0;
@@ -277,18 +278,15 @@
 
 void UMLOperationDialog::slotNewParameter()
 {
-    int result = 0;
     UMLAttribute* pAtt = 0;
 
     QString currentName = m_operation->getUniqueParameterName();
     UMLAttribute* newAttribute = new UMLAttribute(m_operation, currentName, Uml::id_Reserved);
 
-    ParmPropDlg dlg(this, m_doc, newAttribute);
-    result = dlg.exec();
+    QPointer<ParmPropDlg> dlg = new ParmPropDlg(this, m_doc, newAttribute);
+    if ( dlg->exec() ) {
+        pAtt = m_operation->findParm( newAttribute->getName() );
 
-    if ( result ) {
-        pAtt = m_operation -> findParm( newAttribute->getName() );
-
         if ( !pAtt ) {
             newAttribute->setID( UniqueID::gen() );
             m_operation->addParm( newAttribute );
@@ -302,6 +300,7 @@
     } else {
         delete newAttribute;
     }
+    delete dlg;
 }
 
 void UMLOperationDialog::slotDeleteParameter()
@@ -320,7 +319,6 @@
 
 void UMLOperationDialog::slotParameterProperties()
 {
-    int result = 0;
     UMLAttribute* pAtt = 0, * pOldAtt = 0;
 
     int position = m_pParmsLW->row( m_pParmsLW->currentItem() );
@@ -333,10 +331,9 @@
     QString oldAttName = pOldAtt->getName();
     UMLAttribute* tempAttribute = static_cast<UMLAttribute*>( pOldAtt->clone() ); // create a clone of the parameter
 
-    ParmPropDlg dlg(this, m_doc, tempAttribute); // send the clone to the properties dialog box. it will fill in the new parameters.
-    result = dlg.exec();
-
-    if ( result ) {
+    // send the clone to the properties dialog box. it will fill in the new parameters.
+    QPointer<ParmPropDlg> dlg = new ParmPropDlg(this, m_doc, tempAttribute); 
+    if ( dlg->exec() ) {
         bool namingConflict = false;
         QString newName = tempAttribute->getName();
 
@@ -357,6 +354,7 @@
         m_doc->setModified( true );
     }
     delete tempAttribute;
+    delete dlg;
 }
 
 void UMLOperationDialog::slotParameterUp()
@@ -428,7 +426,7 @@
     if( name.length() == 0 ) {
         KMessageBox::error(this, i18n("You have entered an invalid operation name."),
                            i18n("Operation Name Invalid"), false);
-        m_pNameLE -> setText( m_operation -> getName() );
+        m_pNameLE->setText( m_operation->getName() );
         return false;
     }
 
@@ -442,16 +440,16 @@
         KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false);
         return false;
     }
-    m_operation -> setName( name );
+    m_operation->setName( name );
 
-    if( m_pPublicRB -> isChecked() )
-      m_operation -> setVisibility( Uml::Visibility::Public );
-    else if( m_pPrivateRB -> isChecked() )
-      m_operation -> setVisibility( Uml::Visibility::Private );
-    else if (m_pProtectedRB -> isChecked() )
-      m_operation -> setVisibility( Uml::Visibility::Protected );
-    else if (m_pImplementationRB -> isChecked() )
-      m_operation -> setVisibility( Uml::Visibility::Implementation );
+    if( m_pPublicRB->isChecked() )
+      m_operation->setVisibility( Uml::Visibility::Public );
+    else if( m_pPrivateRB->isChecked() )
+      m_operation->setVisibility( Uml::Visibility::Private );
+    else if (m_pProtectedRB->isChecked() )
+      m_operation->setVisibility( Uml::Visibility::Protected );
+    else if (m_pImplementationRB->isChecked() )
+      m_operation->setVisibility( Uml::Visibility::Implementation );
 
     QString typeName = m_pRtypeCB->currentText();
     UMLTemplate *tmplParam = 0;
@@ -466,7 +464,7 @@
     m_operation->setStereotype( m_pStereoTypeCB->currentText() );
 
     bool isAbstract = m_pAbstractCB->isChecked();
-    m_operation -> setAbstract( isAbstract );
+    m_operation->setAbstract( isAbstract );
     if (isAbstract) {
         /* If any operation is abstract then the owning class needs
            to be made abstract.
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #972878:972879
@@ -75,8 +75,9 @@
 #include <kundostack.h>
 
 // qt includes
+#include <QtCore/QPointer>
+#include <QtCore/QRegExp>
 #include <QtCore/QTimer>
-#include <QtCore/QRegExp>
 #include <QtGui/QClipboard>
 #include <QtGui/QSlider>
 #include <QtGui/QToolButton>
@@ -1954,8 +1955,9 @@
  */
 void UMLApp::generationWizard()
 {
-    CodeGenerationWizard wizard(0 /*classList*/);
-    wizard.exec();
+    QPointer<CodeGenerationWizard> wizard = new CodeGenerationWizard(0 /*classList*/);
+    wizard->exec();
+    delete wizard;
 }
 
 /**
@@ -2255,10 +2257,11 @@
 {
     QStringList listFile;
 
-    ImportProjectDlg importDlg(&listFile, m_codegen->getLanguage(), this);
-    if (importDlg.exec() == KDialog::Accepted) {
+    QPointer<ImportProjectDlg> importDlg = new ImportProjectDlg(&listFile, m_codegen->getLanguage(), this);
+    if (importDlg->exec() == KDialog::Accepted) {
         importFiles(&listFile);
     }
+    delete importDlg;
 }
 
 /**
@@ -2266,8 +2269,9 @@
  */
 void UMLApp::slotClassWizard()
 {
-    ClassWizard dlg( m_doc );
-    dlg.exec();
+    QPointer<ClassWizard> dlg  = new ClassWizard( m_doc );
+    dlg->exec();
+    delete dlg;
 }
 
 /**




More information about the umbrello-devel mailing list