Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-41210

QML canvas isn't properly restored when hiding and showing window

    XMLWordPrintable

    Details

    • Commits:
      c2706491906c053f5d38ddc0558a993bbf7cfd3e

      Description

      The following piece of QML work fine with Qt 5.3. The canvas item is blue and becomes blue again when the window is hidden and shown. When I use the same QML with the current state of Qt 5.4 the canvas is cleared on hiding and even cannot be painted to anymore when the window is shown again. It seems the context gets silently destroyed and isn't recreated later.

      import QtQuick 2.2
      import QtQuick.Window 2.1
      
      Window {
          id: root
          visible: true
          width: 360
          height: 360
      
          Timer {
              repeat: true
              interval: 2000
              running: true
              onTriggered: {
                  if (!root.visible) {
                      root.show();
                      //canvas.requestPaint(); <- triggers the "context dead" message on 5.4 but otherwise makes no difference
                  } else {
                      root.hide();
                  }
              }
          }
      
          Canvas {
              id: canvas
              anchors.fill: parent
              contextType: "2d"
              onPaint: {
                  if (context === null) {
                      console.log("context is dead");
                      return; // canvas isn't ready
                  }
      
                  context.reset();
                  context.fillStyle = "blue";
                  context.fillRect(0, 0, width, height);
              }
          }
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            ulherman Ulf Hermann
            Reporter:
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes