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

Andi Fischer andi.fischer at hispeed.ch
Mon May 25 10:25:55 UTC 2009


SVN commit 972572 by fischer:

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

 M  +40 -29    umllistview.cpp  
 M  +7 -4      umlview.cpp  
 M  +5 -3      widgets/statewidget.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #972571:972572
@@ -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>                   *
  ***************************************************************************/
 
@@ -12,10 +12,11 @@
 #include "umllistview.h"
 
 // qt includes
-#include <QRegExp>
-#include <QPoint>
-#include <QRect>
-#include <QEvent>
+#include <QtCore/QPointer>
+#include <QtCore/QRegExp>
+#include <QtCore/QPoint>
+#include <QtCore/QRect>
+#include <QtCore/QEvent>
 #include <q3header.h>
 #include <QFocusEvent>
 #include <QKeyEvent>
@@ -419,16 +420,19 @@
         }
         // configure & show the file dialog
         const QString rootDir(m_doc->url().directory());
-        KFileDialog fileDialog(rootDir, "*.xml", this);
-        fileDialog.setCaption(i18n("Externalize Folder"));
-        fileDialog.setOperationMode(KFileDialog::Other);
+        QPointer<KFileDialog> fileDialog = new KFileDialog(rootDir, "*.xml", this);
+        fileDialog->setCaption(i18n("Externalize Folder"));
+        fileDialog->setOperationMode(KFileDialog::Other);
         // set a sensible default filename
         QString defaultFilename = current->getText().toLower();
         defaultFilename.replace(QRegExp("\\W+"), "_");
         defaultFilename.append(".xml");  // default extension
-        fileDialog.setSelection(defaultFilename);
-        fileDialog.exec();
-        KUrl selURL = fileDialog.selectedUrl();
+        fileDialog->setSelection(defaultFilename);
+        KUrl selURL;
+        if (fileDialog->exec() == QDialog::Accepted) {
+            selURL = fileDialog->selectedUrl();
+        }
+        delete fileDialog;
         if (selURL.isEmpty())
             return;
         QString path = selURL.path();
@@ -436,8 +440,8 @@
         if (fileName.startsWith(rootDir)) {
             fileName.remove(rootDir);
         } else {
-            // This should be done using a KMessageBox but we currently
-            // cannot add new i18n strings.
+            // TODO: This should be done using a KMessageBox but we currently
+            //       cannot add new i18n strings.
             uError() << "Folder " << path
             << " must be relative to the main model directory, "
             << rootDir;
@@ -446,8 +450,8 @@
         QFile file(path);
         // Warn if file exists.
         if (file.exists()) {
-            // This should be done using a KMessageBox but we currently
-            // cannot add new i18n strings.
+            // TODO: This should be done using a KMessageBox but we currently
+            //       cannot add new i18n strings.
             uWarning() << "file " << fileName << " already exists!";
             uWarning() << "The existing file will be overwritten.";
         }
@@ -533,38 +537,45 @@
         } else if (umlType == Uml::ot_Attribute) {
             // show the attribute dialog
             UMLAttribute* selectedAttribute = static_cast<UMLAttribute*>(object);
-            UMLAttributeDialog dialog(this, selectedAttribute);
-            dialog.exec();
+            QPointer<UMLAttributeDialog> dialog = new UMLAttributeDialog(this, selectedAttribute);
+            dialog->exec();
+            delete dialog;
         } else if (umlType == Uml::ot_EntityAttribute) {
             // show the attribute dialog
             UMLEntityAttribute* selectedAttribute = static_cast<UMLEntityAttribute*>(object);
-            UMLEntityAttributeDialog dialog(this, selectedAttribute);
-            dialog.exec();
+            QPointer<UMLEntityAttributeDialog> dialog = new UMLEntityAttributeDialog(this, selectedAttribute);
+            dialog->exec();
+            delete dialog;
         } else if (umlType == Uml::ot_Operation) {
             // show the operation dialog
             UMLOperation* selectedOperation = static_cast<UMLOperation*>(object);
-            UMLOperationDialog dialog(this, selectedOperation);
-            dialog.exec();
+            QPointer<UMLOperationDialog> dialog = new UMLOperationDialog(this, selectedOperation);
+            dialog->exec();
+            delete dialog;
         } else if (umlType == Uml::ot_Template) {
             // show the template dialog
             UMLTemplate* selectedTemplate = static_cast<UMLTemplate*>(object);
-            UMLTemplateDialog dialog(this, selectedTemplate);
-            dialog.exec();
+            QPointer<UMLTemplateDialog> dialog = new UMLTemplateDialog(this, selectedTemplate);
+            dialog->exec();
+            delete dialog;
         } else if (umlType == Uml::ot_UniqueConstraint) {
             // show the Unique Constraint dialog
             UMLUniqueConstraint* selectedUniqueConstraint = static_cast<UMLUniqueConstraint*>(object);
-            UMLUniqueConstraintDialog dialog(this, selectedUniqueConstraint);
-            dialog.exec();
+            QPointer<UMLUniqueConstraintDialog> dialog = new UMLUniqueConstraintDialog(this, selectedUniqueConstraint);
+            dialog->exec();
+            delete dialog;
         } else if (umlType == Uml::ot_ForeignKeyConstraint) {
             // show the Unique Constraint dialog
             UMLForeignKeyConstraint* selectedForeignKeyConstraint = static_cast<UMLForeignKeyConstraint*>(object);
-            UMLForeignKeyConstraintDialog dialog(this, selectedForeignKeyConstraint);
-            dialog.exec();
+            QPointer<UMLForeignKeyConstraintDialog> dialog = new UMLForeignKeyConstraintDialog(this, selectedForeignKeyConstraint);
+            dialog->exec();
+            delete dialog;
         } else if (umlType == Uml::ot_CheckConstraint) {
             // show the Check Constraint dialog
             UMLCheckConstraint* selectedCheckConstraint = static_cast<UMLCheckConstraint*>(object);
-            UMLCheckConstraintDialog dialog(this, selectedCheckConstraint);
-            dialog.exec();
+            QPointer<UMLCheckConstraintDialog> dialog = new UMLCheckConstraintDialog(this, selectedCheckConstraint);
+            dialog->exec();
+            delete dialog;
         } else {
             uWarning() << "calling properties on unknown type";
         }
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #972571:972572
@@ -16,6 +16,7 @@
 #include <math.h>
 
 // include files for Qt
+#include <QtCore/QPointer>
 #include <QtCore/QString>
 #include <QtCore/QStringList>
 #include <QtCore/QVector>
@@ -2852,11 +2853,13 @@
 
 bool UMLView::showPropDialog()
 {
-    UMLViewDialog dlg(this, this);
-    if (dlg.exec()) {
-        return true;
+    bool success = false;
+    QPointer<UMLViewDialog> dlg = new UMLViewDialog(this, this);
+    if (dlg->exec() == QDialog::Accepted) {
+        success = true;
     }
-    return false;
+    delete dlg;
+    return success;
 }
 
 QFont UMLView::getFont() const
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/statewidget.cpp #972571:972572
@@ -12,7 +12,8 @@
 #include "statewidget.h"
 
 // qt includes
-#include <QEvent>
+#include <QtCore/QPointer>
+#include <QtCore/QEvent>
 
 // kde includes
 #include <klocale.h>
@@ -231,11 +232,12 @@
     DocWindow *docwindow = UMLApp::app()->getDocWindow();
     docwindow->updateDocumentation(false);
 
-    StateDialog dialog(m_pView, this);
-    if (dialog.exec() && dialog.getChangesMade()) {
+    QPointer<StateDialog> dialog = new StateDialog(m_pView, this);
+    if (dialog->exec() && dialog->getChangesMade()) {
         docwindow->showDocumentation(this, true);
         UMLApp::app()->getDocument()->setModified(true);
     }
+    delete dialog;
 }
 
 bool StateWidget::isState(WorkToolBar::ToolBar_Buttons tbb, StateType& resultType)




More information about the umbrello-devel mailing list