Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Strange errors from paintEngine

Strange errors from paintEngine

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 4 Posters 1.6k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    drmhkelley
    wrote on last edited by
    #1

    In an app I've been developing, I've started to get a huge number of error messages related to QWidget::paintEngine and QPainter. I just noticed them for the first time this evening, bug am not really certain when they started. The errors are of the form shown below, and just about anything I do with the app triggers many of these errors.

    How do I start to find the ultimate source of these errors? I haven't a clue what part of the app uses these components.

    For reference, the the app is essentially a collection of text widgets - QLabels, QPushButtons,QLineEditors, QComboBoxes, QTextEditors, etc. packaged into various layout widgets.

    What sorts of components need/use paintEngine and QPainter? I've not previously been aware of them.

    Thanks for any clues where to begin.


    QWidget::paintEngine: Should no longer be called
    QPainter::begin: Paint device returned engine == 0, type: 1
    QPainter::translate: Painter not active
    QPainter::save: Painter not active
    QPainter::setClipRect: Painter not active
    QPainter::pen: Painter not active
    QPainter::setPen: Painter not active
    QPainter::pen: Painter not active
    QPainter::setPen: Painter not active
    QPainter::restore: Unbalanced save/restore
    QPainter::setPen: Painter not active

    jsulmJ 1 Reply Last reply
    0
    • D drmhkelley

      In an app I've been developing, I've started to get a huge number of error messages related to QWidget::paintEngine and QPainter. I just noticed them for the first time this evening, bug am not really certain when they started. The errors are of the form shown below, and just about anything I do with the app triggers many of these errors.

      How do I start to find the ultimate source of these errors? I haven't a clue what part of the app uses these components.

      For reference, the the app is essentially a collection of text widgets - QLabels, QPushButtons,QLineEditors, QComboBoxes, QTextEditors, etc. packaged into various layout widgets.

      What sorts of components need/use paintEngine and QPainter? I've not previously been aware of them.

      Thanks for any clues where to begin.


      QWidget::paintEngine: Should no longer be called
      QPainter::begin: Paint device returned engine == 0, type: 1
      QPainter::translate: Painter not active
      QPainter::save: Painter not active
      QPainter::setClipRect: Painter not active
      QPainter::pen: Painter not active
      QPainter::setPen: Painter not active
      QPainter::pen: Painter not active
      QPainter::setPen: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::setPen: Painter not active

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @drmhkelley Do you call https://doc.qt.io/qt-5/qwidget.html#paintEngine anywhere in your app directly? Or do you use any third party libraries in your project?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drmhkelley
        wrote on last edited by
        #3

        I don't knowingly call paint

        jsulmJ 1 Reply Last reply
        0
        • D drmhkelley

          I don't knowingly call paint

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @drmhkelley What about my second question?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • D Offline
            D Offline
            drmhkelley
            wrote on last edited by
            #5

            I don't knowingly call paintEngine anywhere in my code. I do use third party libraries - some really third party and some where I am the third party. None of those libraries have any reason to interact with paintEngine directly.

            jsulmJ 1 Reply Last reply
            0
            • D drmhkelley

              I don't knowingly call paintEngine anywhere in my code. I do use third party libraries - some really third party and some where I am the third party. None of those libraries have any reason to interact with paintEngine directly.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @drmhkelley Can you reproduce this issue with a simple Qt GUI application?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • D Offline
                D Offline
                drmhkelley
                wrote on last edited by
                #7

                Working on that part. I just ran another of my apps and it does not exhibit this behavior. It uses most of the same basic components and libraries, plus a bunch more. The second is a plotting app I use a lot, so I thought it might place more demands on many aspects of the the graphics sub-components. It does use most of the same text widgets.

                jsulmJ 1 Reply Last reply
                0
                • D drmhkelley

                  Working on that part. I just ran another of my apps and it does not exhibit this behavior. It uses most of the same basic components and libraries, plus a bunch more. The second is a plotting app I use a lot, so I thought it might place more demands on many aspects of the the graphics sub-components. It does use most of the same text widgets.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @drmhkelley I think one of the libs you're using causes this warnings. Try to disable one by one until there are no warnings any-more, then you know where the problem is.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • B Offline
                    B Offline
                    Bonnie
                    wrote on last edited by
                    #9

                    Hi, have you ever used QPainter in any widgets then?

                    D 1 Reply Last reply
                    0
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      @drmhkelley said

                      How do I start to find the ultimate source of these errors?

                      hi
                      You can also use the message handler trick
                      https://stackoverflow.com/questions/4954140/how-to-redirect-qdebug-qwarning-qcritical-etc-output

                      where you redirect all messages to your own function and there do a if/string compare with a breakpoint.
                      So when your breakpoint is triggered, you can see where the message comes from via the call stack.

                      D 2 Replies Last reply
                      2
                      • B Bonnie

                        Hi, have you ever used QPainter in any widgets then?

                        D Offline
                        D Offline
                        drmhkelley
                        wrote on last edited by
                        #11

                        @Bonnie - I have never used QPainter, at least not directly. I found reference to in in one 3rd party package I use quite often, but it is not used in my the app currently under consideration. And one app that does use that package does not exhibit the symptom.

                        B 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @drmhkelley said

                          How do I start to find the ultimate source of these errors?

                          hi
                          You can also use the message handler trick
                          https://stackoverflow.com/questions/4954140/how-to-redirect-qdebug-qwarning-qcritical-etc-output

                          where you redirect all messages to your own function and there do a if/string compare with a breakpoint.
                          So when your breakpoint is triggered, you can see where the message comes from via the call stack.

                          D Offline
                          D Offline
                          drmhkelley
                          wrote on last edited by
                          #12

                          @mrjj - Thank you for this suggestion. I have not tried this before, but it does sound like it will get me much closer much quicker.

                          1 Reply Last reply
                          0
                          • D drmhkelley

                            @Bonnie - I have never used QPainter, at least not directly. I found reference to in in one 3rd party package I use quite often, but it is not used in my the app currently under consideration. And one app that does use that package does not exhibit the symptom.

                            B Offline
                            B Offline
                            Bonnie
                            wrote on last edited by
                            #13

                            @drmhkelley
                            I'm not sure what is your situation here, but from my experience, this kind of error usually caused by calling something like

                            QPainter p(this);
                            //use p to draw something
                            

                            outside the paintEvent of a widget.

                            1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @drmhkelley said

                              How do I start to find the ultimate source of these errors?

                              hi
                              You can also use the message handler trick
                              https://stackoverflow.com/questions/4954140/how-to-redirect-qdebug-qwarning-qcritical-etc-output

                              where you redirect all messages to your own function and there do a if/string compare with a breakpoint.
                              So when your breakpoint is triggered, you can see where the message comes from via the call stack.

                              D Offline
                              D Offline
                              drmhkelley
                              wrote on last edited by
                              #14

                              @mrjj - Again, thanks very much for this suggestion. Solved my problem immediately. Had I been aware of this in the past, I would have addressed several glitches much more easily. Will now be a standard part of my toolkit.

                              As is too often the case, it solved my immediate problem, but now has me curious why I only now discovered that I should have been aware of the underlying problem long ago.

                              Detailed info follows.

                              It is often the case that the out-of-the-box QWidgets don't offer quite the capabilities I expect, so I've put wrappers around several to better meet my expectations. In this particular case, I wanted to intercept a couple of QEvents to process on my own while passing the bulk of QEvents on to Qt. I've done this for about a dozen QWidgets, including QLineEdit and QTextEdit. My version of the former I use a lot, the latter much less often.

                              My mistake was that for all such wrapper widgets, I passed the intercepted to QWidget, not specifically to QLineEdit or QTextEdit as I should have. In any event, Qt was quite unhappy that I passed events intended specifically for QTextEdit to QWidget.

                              I'm not surprised that this mistake would lead to unexpected outcomes. I am surprised that doing so for QTextEdit led to such different outcomes that QLineEdit, QLabel, QPushButton, QDateEdit, QSpinBox, QCalendar, QComboBox, etc.

                              1 Reply Last reply
                              1

                              • Login

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