Bug 417844 - Kirigami Icon crashes in RowLayout without explicit width/height
Summary: Kirigami Icon crashes in RowLayout without explicit width/height
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: Master
Platform: unspecified All
: NOR crash
Target Milestone: Not decided
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-18 21:26 UTC by mtmcp
Modified: 2020-02-20 11:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.68


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mtmcp 2020-02-18 21:26:59 UTC
SUMMARY
Instantiating a Kirigami.Icon within a RowLayout causes a crash when no Layout.preferredHeight/Layout.preferredWidth is specified.

STEPS TO REPRODUCE
1. Create a Kirigami.OverlaySheet with a header as follows:
Kirigami.OverlaySheet {
    id: sheet
        header: RowLayout {
            Kirigami.Icon {
                source: "dialog-error"
            }
        }
    // ...
}
2. Invoke sheet.open() to trigger the crash

OBSERVED RESULT
Application crashes

EXPECTED RESULT
Icon to render using implicit height/widths as loaded by the underlying QIcon

SOFTWARE/OS VERSIONS
Windows: Windows 10
Android: Android Emulator
macOS: NA
Linux/KDE Plasma: NA
(available in About System)
KDE Plasma Version: NA
KDE Frameworks Version: Kirigami master
Qt Version: 5.12.6

ADDITIONAL INFORMATION
When setting Layout.preferredHeight or Layout.preferredWidth explicitly, the system does not crash. This seems like there's an issue where the RowLayout is maybe setting the width/height to zero, or something invalid.
Comment 1 Arjen Hiemstra 2020-02-20 11:42:44 UTC
Git commit fcae16b30b0626a40d7eaf49c3571f3d3af0630b by Arjen Hiemstra.
Committed on 20/02/2020 at 11:42.
Pushed by ahiemstra into branch 'master'.

Do not crash when icon's width or height is 0

Summary:
When Icon's width or height is 0, I get a crash with the following backtrace:

    #0  0x00007ffff7b9cd30 in QSGTexture::setFiltering(QSGTexture::Filtering) () from /usr/lib/libQt5Quick.so.5
    #1  0x00007ffff7bd439c in QSGOpaqueTextureMaterialShader::updateState(QSGMaterialShader::RenderState const&, QSGMaterial*, QSGMaterial*) () from /usr/lib/libQt5Quick.so.5
    #2  0x00007ffff7bb7857 in QSGBatchRenderer::Renderer::renderMergedBatch(QSGBatchRenderer::Batch const*) () from /usr/lib/libQt5Quick.so.5
    #3  0x00007ffff7bbd5b6 in QSGBatchRenderer::Renderer::renderBatches() () from /usr/lib/libQt5Quick.so.5
    #4  0x00007ffff7bbdcc5 in QSGBatchRenderer::Renderer::render() () from /usr/lib/libQt5Quick.so.5
    #5  0x00007ffff7ba1832 in QSGRenderer::renderScene(QSGBindable const&) () from /usr/lib/libQt5Quick.so.5
    #6  0x00007ffff7ba1d14 in QSGRenderer::renderScene(unsigned int) () from /usr/lib/libQt5Quick.so.5
    #7  0x00007ffff7c10713 in QSGDefaultRenderContext::renderNextFrame(QSGRenderer*, unsigned int) () from /usr/lib/libQt5Quick.so.5
    #8  0x00007ffff7c7b3a1 in QQuickWindowPrivate::renderSceneGraph(QSize const&, QSize const&) () from /usr/lib/libQt5Quick.so.5

This patch prevents Icon from doing anything when width or height is 0, avoiding the crash.
FIXED-IN: 5.68

Test Plan:
The following QML code, when ran through qmlscene, no longer crashes:

```
import QtQuick 2.12
import org.kde.kirigami 2.11 as Kirigami
Item {
    Kirigami.Icon { source: "document-new" }
}
```

Reviewers: #kirigami, davidedmundson

Reviewed By: davidedmundson

Subscribers: ngraham, davidedmundson, plasma-devel

Tags: #kirigami

Differential Revision: https://phabricator.kde.org/D27505

M  +1    -1    src/icon.cpp

https://commits.kde.org/kirigami/fcae16b30b0626a40d7eaf49c3571f3d3af0630b