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

Ralf Habacker Ralf.Habacker at freenet.de
Mon Jan 26 22:43:48 UTC 2009


SVN commit 917130 by habacker:

crash fix: completed feature of calling a popup menu selection handler from a another popup menu selection handler - it is required to setup m_pMenu before 


 M  +4 -0      associationwidget.cpp  
 M  +1 -2      floatingtextwidget.cpp  
 M  +0 -2      floatingtextwidget.h  
 M  +13 -4     umlwidget.cpp  
 M  +8 -2      umlwidget.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/associationwidget.cpp #917129:917130
@@ -2400,6 +2400,9 @@
     m_pMenu = new ListPopupMenu(m_pView, menuType);
     m_pMenu->popup(me -> globalPos());
     connect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
+    if (isCollaboration()) 
+        m_pName->setupPopupMenu(m_pMenu);
+
     setSelected();
 }//end method mouseReleaseEvent
 
@@ -3190,6 +3193,7 @@
 void AssociationWidget::slotRemovePopupMenu()
 {
     if(m_pMenu) {
+        m_pName->slotRemovePopupMenu();
         disconnect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
         delete m_pMenu;
         m_pMenu = 0;
--- trunk/KDE/kdesdk/umbrello/umbrello/floatingtextwidget.cpp #917129:917130
@@ -95,8 +95,6 @@
 
 void FloatingTextWidget::slotMenuSelection(QAction* action)
 {
-    if (!m_pMenu)
-        return;
     ListPopupMenu::Menu_Type sel = m_pMenu->getMenuType(action);
     switch(sel) {
     case ListPopupMenu::mt_Properties:
@@ -107,6 +105,7 @@
         m_pView -> removeWidget(this);
         break;
 
+    case ListPopupMenu::mt_New_Operation: // needed by AssociationWidget
     case ListPopupMenu::mt_Operation:
         {
             if (m_pLink == NULL) {
--- trunk/KDE/kdesdk/umbrello/umbrello/floatingtextwidget.h #917129:917130
@@ -255,8 +255,6 @@
 public slots:
     /**
      * Called when a menu selection has been made.
-     * This method is public due to called by @ref MessageWidget
-     * when this is text for a @ref MessageWidget.
      *
      * @param action  The action that has been selected.
      */
--- trunk/KDE/kdesdk/umbrello/umbrello/umlwidget.cpp #917129:917130
@@ -41,7 +41,7 @@
 
 UMLWidget::UMLWidget(UMLView * view, UMLObject * o, UMLWidgetController *widgetController /* = 0*/)
         : WidgetBase(view), Q3CanvasRectangle(view->canvas()),
-        m_pMenu(0)
+        m_pMenu(0), m_menuIsEmbedded(false)
 {
     if (widgetController) {
         m_widgetController = widgetController;
@@ -651,10 +651,17 @@
     dlg->close(); //wipe from memory
 }
 
-ListPopupMenu*  UMLWidget::setupPopupMenu()
+ListPopupMenu*  UMLWidget::setupPopupMenu(ListPopupMenu* menu)
 {
     slotRemovePopupMenu();
 
+    if (menu) {
+        m_pMenu = menu;
+        m_menuIsEmbedded = true;
+        return m_pMenu;
+    }
+
+    m_menuIsEmbedded = false;
     //if in a multi- selection to a specific m_pMenu for that
     // NEW: ask UMLView to count ONLY the widgets and not their floatingtextwidgets
     int count = m_pView->getSelectCount(true);
@@ -687,8 +694,10 @@
 void UMLWidget::slotRemovePopupMenu()
 {
     if (m_pMenu) {
-        disconnect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
-        delete m_pMenu;
+        if (!m_menuIsEmbedded) {
+            disconnect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
+            delete m_pMenu;
+        }
         m_pMenu = 0;
     }
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/umlwidget.h #917129:917130
@@ -458,10 +458,15 @@
     virtual QString getName() const;
 
     /**
-     * Starts the popup menu.
+     * Starts the popup menu. If menu is non zero,
+     * the widgets popup menu is embedded into another widget. 
+     * The another widget is responsible for calling 
+     * setupPopupMenu(), slotMenuSelection() and 
+     * removePopupMenu() manually.
      *
+     * @return pointer to the popup menu object
      */
-    virtual ListPopupMenu* setupPopupMenu();
+    virtual ListPopupMenu* setupPopupMenu(ListPopupMenu *menu=0);
 
     /**
      * Adjusts associations with the given co-ordinates
@@ -658,6 +663,7 @@
     int            m_nPosX;
     int            m_origZ;
     ListPopupMenu *m_pMenu;
+    bool           m_menuIsEmbedded;
     UMLDoc        *m_pDoc;  ///< shortcut for UMLApp::app()->getDocument()
     bool           m_bResizable;
     QFontMetrics  *m_pFontMetrics[FT_INVALID];




More information about the umbrello-devel mailing list