Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Canvas causing crash

QML Canvas causing crash

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stevenhurd
    wrote on last edited by
    #1

    My application is essentially a dynamically created set of pages (similar to PageStack) with a ListView as one of the contained items. I've was using a Canvas as the ListView highlight component, which works great until a page is destroyed (or a previously painted page is repainted, not sure which). I'm not entirely sure what is going on here and could use some ideas. My ListView looks something like:

    @
    ListView {
    highlight: Canvas {
    id: canvas
    antialiasing: true
    renderTarget: Canvas.Image

            onPaint: {
                var ctx = canvas.getContext('2d');
                ctx.save()
    
                ctx.fillStyle = "#555555"
                // Draw shapes
                ctx.clearRect(0,0,canvas.width, canvas.height);
                ctx.beginPath();
                ctx.moveTo(0,0)
                ctx.lineTo(0, canvas.height)
                ctx.lineTo(canvas.width*.93, canvas.height)
                ctx.lineTo(canvas.width, canvas.height/2)
                ctx.lineTo(canvas.width*.93, 0)
                ctx.lineTo(canvas.width*.93, 0)
                ctx.lineTo(0, 0)
                ctx.fill()
                ctx.restore()
            }
        }
    
        model: myModel
        delegate: Text {
            text: modelText
       }
    

    }
    @

    I've noticed that I can comment out everything in the onPaint handler EXCEPT the getContext line, I still get the crash, so I'm assuming something about getContext is going wrong.

    Any help or ideas to debug this would be appreciated, thanks.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      Can you paste a stacktrace of the crash? My guess is that in the crash case, the calling context is null because the component has been destroyed (and it presumably owns its own evaluation context).

      Either way, please file a bug report in JIRA and include all of the pertinent information as well as a minimal example which demonstrates the issue.

      Cheers,
      Chris.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stevenhurd
        wrote on last edited by
        #3

        Here's a copy of the stack trace. I will try to create a simplified example and file a bug with it.

        0 QQuickFlickable::movementStarted Qt5Quickd 0x55c4619f
        1 QQuickFlickable::movementStarted Qt5Quickd 0x55b025a8
        2 QQuickFlickable::movementStarted Qt5Quickd 0x55b017f1
        3 QQuickFlickable::movementStarted Qt5Quickd 0x55afb979
        4 QQuickFlickable::movementStarted Qt5Quickd 0x55c2e7ae
        5 QQuickFlickable::movementStarted Qt5Quickd 0x55c2ed35
        6 QWidget::normalGeometry Qt5Widgetsd 0x5280291e
        7 QWidget::normalGeometry Qt5Widgetsd 0x5280035a
        8 QTimer::isSingleShot Qt5Cored 0x552a8264
        9 QTimer::isSingleShot Qt5Cored 0x552ad5e9
        10 QTimer::isSingleShot Qt5Cored 0x552a90e5
        11 QTimer::isSingleShot Qt5Cored 0x552a8d9d
        12 QCss::StyleSelector::selectorMatches Qt5Guid 0x533e84dd
        13 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 86 0x524cc014
        14 QTimer::isSingleShot Qt5Cored 0x553308d7
        15 InternalCallWinProc USER32 0x756662fa
        16 UserCallWinProcCheckWow USER32 0x75666d3a
        17 DispatchMessageWorker USER32 0x756677c4
        18 DispatchMessageW USER32 0x7566788a
        19 QTimer::isSingleShot Qt5Cored 0x553319c3
        20 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 78 0x524cbf7e
        21 QTimer::isSingleShot Qt5Cored 0x552a4ea1
        22 QTimer::isSingleShot Qt5Cored 0x552a4ffe
        23 QTimer::isSingleShot Qt5Cored 0x552a879d
        24 QCss::StyleSelector::selectorMatches Qt5Guid 0x533ff5e8
        25 QWidget::normalGeometry Qt5Widgetsd 0x52800009
        26 main main.cpp 78 0xe9ccfb
        27 WinMain qtmain_win.cpp 131 0xf4754a
        28 __tmainCRTStartup crtexe.c 547 0xf46ba0
        29 WinMainCRTStartup crtexe.c 371 0xf4692f
        30 BaseThreadInitThunk kernel32 0x766a33aa
        31 __RtlUserThreadStart ntdll32 0x77629ef2
        32 _RtlUserThreadStart ntdll32 0x77629ec5

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stevenhurd
          wrote on last edited by
          #4

          Bug reported with sample project here:
          https://bugreports.qt-project.org/browse/QTBUG-30810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved