Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ColorOverlay causing segmentation fault



  • Hello, developing an ColumnLayout with labels preceded by icons i stumbled upon an strange issue:

    Code below works fine and as i want which is drawing a column of icon + text records. But unfortunately when i quit the application it crashes on destructor of class exporting QML classes from C++ (callstack below).

    I figured out that commenting out ScalingIcon's ColorOverlay is solving the issue, why i that and ow can i fix it?

    ScalingIcon.qml

    Image {
        id: root
        property int size: 24  // default
        property real scalingFactor: 1
    
        sourceSize.width: size * scalingFactor
        sourceSize.height: size * scalingFactor
    
        ColorOverlay {
            id: colorOverlay
            anchors.fill: root
            source: root
            color: "white"
        }
    }
    

    myWidget.qml

    	Component
    	{
    		id: overlayIconItem
    
    		Row
    		{
    			ScalingIcon
    			{
    				id: scalingIcon
                	                source: "myIcon.svg"
    				size: label.font.pixelSize
    			}
    
    			Label
    			{
    				id: label
    
    				text: "sample Text"
    
    				color: "white"
    				wrapMode: Text.Wrap
    
    				style: Text.Outline
    				styleColor: "black"
    
    				Component.onCompleted:
    				{
    					font.weight = Font.Bold
    					font.pixelSize = 24
    				}
    
    				Rectangle
    				{
    					z: -1
    					opacity: 0.25
    					color: "grey"
    					height: parent.contentHeight
    					width: parent.contentWidth
    					radius: 2
    				}
    			}
    		}
    
    	}
    
    ColumnLayout{
    Loader
    {
    	sourceComponent: overlayIconItem
    }
    ...
    }
    
    #0  0x00007ffff3d4d205 in QQuickWindow::mouseGrabberItem() const ()
        at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #1  0x00007ffff3d4f8a4 in QQuickWindowPrivate::removeGrabber(QQuickItem*, bool, bool) ()
        at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #2  0x00007ffff3d3d370 in QQuickItemPrivate::derefWindow() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #3  0x00007ffff3d3d8d7 in QQuickItem::setParentItem(QQuickItem*) ()
        at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #4  0x00007ffff3d3e34c in QQuickItem::~QQuickItem() () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #5  0x00007ffff3d5a36d in  () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #6  0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #7  0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #8  0x00007ffff3d3e455 in QQuickItem::~QQuickItem() () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #9  0x00007ffff3d5aff5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #10 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #11 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #12 0x00007ffff3d3e455 in QQuickItem::~QQuickItem() () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #13 0x00007fff97a48738 in  ()
        at /usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Layouts/libqquicklayoutsplugin.so
    #14 0x00007fff97a44460 in  ()
        at /usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Layouts/libqquicklayoutsplugin.so
    #15 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #16 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #17 0x00007ffff3d3e455 in QQuickItem::~QQuickItem() () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #18 0x00007fff97a48738 in  ()
        at /usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Layouts/libqquicklayoutsplugin.so
    #19 0x00007fff97a44320 in  ()
        at /usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Layouts/libqquicklayoutsplugin.so
    #20 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #21 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #22 0x00007ffff3d3e455 in QQuickItem::~QQuickItem() () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #23 0x00007ffff3d5a765 in  () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #24 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #25 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #26 0x00007ffff3d3e455 in QQuickItem::~QQuickItem() () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #27 0x00007ffff3d598f5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
    #28 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #29 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #30 0x00007ffff3796b9b in  () at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
    #31 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
    ---Type <return> to continue, or q <return> to quit---
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #32 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #33 0x00007ffff3796b9b in  () at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
    #34 0x00007ffff295b13b in QObjectPrivate::deleteChildren() ()
        at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #35 0x00007ffff296496b in QObject::~QObject() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
    #36 0x00007ffff3796b9b in  () at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
    #37 0x00005555570ba57e in std::default_delete<QObject>::operator()(QObject*) const (this=0x5555631a45d8, __ptr=0x555563374e30) at /usr/include/c++/7/bits/unique_ptr.h:78
    #38 0x00005555570af6c3 in std::unique_ptr<QObject, std::default_delete<QObject> >::~unique_ptr() (this=0x5555631a45d8, __in_chrg=<optimized out>) at /usr/include/c++/7/bits/unique_ptr.h:263