Bug 409631

Summary: Associations are sometime not addable in class diagram
Product: [Applications] umbrello Reporter: Ralf Habacker <ralf.habacker>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 2.28.2 (KDE Applications 19.04.2)   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed In: 2.29.90 (KDE Applications 19.11.90)

Description Ralf Habacker 2019-07-08 20:49:31 UTC
One user reported today that after placing multiple classes in a class diagram, adding associations will sometimes no longer work without further hints or error messages.

STEPS TO REPRODUCE
not reproducable yet 

OBSERVED RESULT
The requested association is not added to the diagram

EXPECTED RESULT
The requested association should be added to the diagram

SOFTWARE/OS VERSIONS
Windows: 7

ADDITIONAL INFORMATION
Comment 1 Ralf Habacker 2019-11-25 13:07:15 UTC
Today I got the same error with a component diagram. After selecting the first widget clicking on the second widget do not connect both widgets. 
In a debug session it turned out that in the error case  UMLScene::widgetAt(m_pMouseEvent->scenePos()) did not return the second widget in 

void ToolBarState::setCurrentElement()
{
    ... 
    // Check widgets.
    UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->scenePos());
    if (widget) {
        setCurrentWidget(widget);
        return;
    }
}
Comment 2 Ralf Habacker 2019-11-25 14:56:24 UTC
STEPS TO REPRODUCE
1. start umbrello
2. add two classes
3. move second widget
4. add an association from first to second widget

OBSERVED RESULT
The requested association is not added to the diagram

EXPECTED RESULT
The requested association should be added to the diagram
Comment 3 Ralf Habacker 2019-11-25 15:32:57 UTC
In normal case UMLWidget* UMLScene::widgetAt(const QPointF& p) returns correct widget instances

1. click
ClassifierWidget(0x1e64b40)  

2. click
ClassifierWidget(0x1d14670)


In the error case there is returned: 

1. click
ClassifierWidget(this = 0x1d14680) 

2. click
QGraphicsItem (0x15fdad0)

which obviously isn't the right widget.
Comment 4 Ralf Habacker 2019-11-26 07:41:48 UTC
Git commit 3921d117b7b6dba3a7860e35b7266bc49d2a02b4 by Ralf Habacker.
Committed on 25/11/2019 at 15:46.
Pushed by habacker into branch 'release/19.12'.

Fix 'Associations are sometime not addable in class diagram'

On error, itemAt() returned the graphical element for the visual
connection, not the selected widget.

BUG:409631
FIXED-IN:2.29.90 (KDE Applications 19.11.90)

M  +11   -6    umbrello/umlscene.cpp

https://invent.kde.org/kde/umbrello/commit/3921d117b7b6dba3a7860e35b7266bc49d2a02b4