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. How to locate where the qt asserts happens
Forum Updated to NodeBB v4.3 + New Features

How to locate where the qt asserts happens

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 691 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.
  • J Jakob Clausen

    Hi.

    I get this output from my application. Many times.

    QFont::setPointSizeF: Point size <= 0 (0.000000), must be greater than 0
    

    How do I find out where in the code, this happens. I use QFont::setPointSizeF but comment those calls out, then I still get it.

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #2

    @Jakob-Clausen
    I believe the message will come through standard Qt message handling. See QtMessageHandler qInstallMessageHandler(QtMessageHandler handler). Install your own message handler, run under debugger, put a breakpoint into that function. Look at the stack trace pane in the debugger when that message arrives.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jakob Clausen
      wrote on last edited by
      #3

      Wow. That actually worked.

      I have a breakpoint where the output arrives at the messagehandler. But it looks like it is happening in the QLabel::paintEvent. But that cannot be right? I have a widget that is derived from QLabel with a custom paintEvent, which calls the QLabel::paintEvent.
      My stack trace looks like this.

                                                                                              
                                                                                              
      1   QMessageLogger::warning(const char *, ...) const *plt                0x7ffff7042710 
      2   QFont::setPointSizeF(double)                                         0x7ffff7121d0a 
      3   ??                                                                   0x7ffff71d0f40 
      4   QCss::ValueExtractor::extractFont(QFont *, int *)                    0x7ffff71d2714 
      5   QCss::ValueExtractor::extractFont()                                  0x7ffff71d28f3 
      6   QCss::ValueExtractor::extractBox(int *, int *, int *)                0x7ffff71dca29 
      7   ??                                                                   0x7ffff719583c 
      8   ??                                                                   0x7ffff71968c3 
      9   ??                                                                   0x7ffff7196b18 
      10  ??                                                                   0x7ffff719890e 
      11  ??                                                                   0x7ffff71990e8 
      12  ??                                                                   0x7ffff71b9dae 
      13  QTextDocument::setHtml(QString const&)                               0x7ffff717c863 
      14  ??                                                                   0x7ffff7932c75 
      15  ??                                                                   0x7ffff7932d85 
      16  ??                                                                   0x7ffff7934580 
      17  QLabel::paintEvent(QPaintEvent *)                                    0x7ffff7934bc0 
      18  Widget::paintEvent                                    Widget.cpp 195 0x5555555d979f 
      19  QWidget::event(QEvent *)                                             0x7ffff7823cb4 
      20  QFrame::event(QEvent *)                                              0x7ffff792e756 
      ... <More>                                                                              
      
      
      JonBJ 1 Reply Last reply
      0
      • J Jakob Clausen

        Wow. That actually worked.

        I have a breakpoint where the output arrives at the messagehandler. But it looks like it is happening in the QLabel::paintEvent. But that cannot be right? I have a widget that is derived from QLabel with a custom paintEvent, which calls the QLabel::paintEvent.
        My stack trace looks like this.

                                                                                                
                                                                                                
        1   QMessageLogger::warning(const char *, ...) const *plt                0x7ffff7042710 
        2   QFont::setPointSizeF(double)                                         0x7ffff7121d0a 
        3   ??                                                                   0x7ffff71d0f40 
        4   QCss::ValueExtractor::extractFont(QFont *, int *)                    0x7ffff71d2714 
        5   QCss::ValueExtractor::extractFont()                                  0x7ffff71d28f3 
        6   QCss::ValueExtractor::extractBox(int *, int *, int *)                0x7ffff71dca29 
        7   ??                                                                   0x7ffff719583c 
        8   ??                                                                   0x7ffff71968c3 
        9   ??                                                                   0x7ffff7196b18 
        10  ??                                                                   0x7ffff719890e 
        11  ??                                                                   0x7ffff71990e8 
        12  ??                                                                   0x7ffff71b9dae 
        13  QTextDocument::setHtml(QString const&)                               0x7ffff717c863 
        14  ??                                                                   0x7ffff7932c75 
        15  ??                                                                   0x7ffff7932d85 
        16  ??                                                                   0x7ffff7934580 
        17  QLabel::paintEvent(QPaintEvent *)                                    0x7ffff7934bc0 
        18  Widget::paintEvent                                    Widget.cpp 195 0x5555555d979f 
        19  QWidget::event(QEvent *)                                             0x7ffff7823cb4 
        20  QFrame::event(QEvent *)                                              0x7ffff792e756 
        ... <More>                                                                              
        
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #4

        @Jakob-Clausen said in How to locate where the qt asserts happens:

        13 QTextDocument::setHtml(QString const&)

        When you are stopped on the breakpoint in the debugger, click on this line to make it "the current frame". With luck you can then use the Watch or Expression panes to view what is in the QString parameter. Does it contain some request for a particular font, or "size 0", or similar?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jakob Clausen
          wrote on last edited by
          #5

          No such luck.

          As you can see here, most of the trace is grayed out, so I cannot select it.
          0c8e04f8-f372-40cd-8447-e94aef1793d3-image.png

          When I singlestep through the code the first part, that I recognize as my own is the re implementation of QLabel::paintEvent. Could it be that it calls setPointSizeF, with an argument, that comes from somewhere else?

          3d13f460-701d-47e2-a5b4-69394d38504d-image.png

          JonBJ 1 Reply Last reply
          0
          • J Jakob Clausen

            No such luck.

            As you can see here, most of the trace is grayed out, so I cannot select it.
            0c8e04f8-f372-40cd-8447-e94aef1793d3-image.png

            When I singlestep through the code the first part, that I recognize as my own is the re implementation of QLabel::paintEvent. Could it be that it calls setPointSizeF, with an argument, that comes from somewhere else?

            3d13f460-701d-47e2-a5b4-69394d38504d-image.png

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #6

            @Jakob-Clausen
            Yes, QLabel painting will doubtless set a font.
            From the error message, verify what the font size is on that QLabel?
            You might as well comment out the shape... code or this whole override, the error presumably still occurs without it?

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jakob Clausen
              wrote on last edited by
              #7

              I have tried with this

              void Widget::paintEvent(QPaintEvent* event)
              {
                  QFontInfo info = fontInfo();
                  qDebug() << name << info.pixelSize() << info.pointSizeF();
              
                  //shape.paintSquare();
                  QLabel::paintEvent(event);
              }
              

              And I never get a pixelsize that is zero or negative.

              JonBJ 1 Reply Last reply
              0
              • J Jakob Clausen

                I have tried with this

                void Widget::paintEvent(QPaintEvent* event)
                {
                    QFontInfo info = fontInfo();
                    qDebug() << name << info.pixelSize() << info.pointSizeF();
                
                    //shape.paintSquare();
                    QLabel::paintEvent(event);
                }
                

                And I never get a pixelsize that is zero or negative.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #8

                @Jakob-Clausen
                Looking through the stack trace I think you will find the QFont::setPointSizeF(double) is being called internally by Qt from source line https://codebrowser.dev/qt5/qtbase/src/gui/text/qcssparser.cpp.html#1143.

                This means it is being called from a CSS/QSS stylesheet string, looking like <number>pt and, for whatever reason, that string's <number> is <= 0.

                • Comment out all your own stylesheet directives wherever they are. Does that solve?
                • Check the string being passed into setHtml(QString const&). Does that have something like this, to do with a font size, in the HTML?
                J 1 Reply Last reply
                0
                • JonBJ JonB

                  @Jakob-Clausen
                  Looking through the stack trace I think you will find the QFont::setPointSizeF(double) is being called internally by Qt from source line https://codebrowser.dev/qt5/qtbase/src/gui/text/qcssparser.cpp.html#1143.

                  This means it is being called from a CSS/QSS stylesheet string, looking like <number>pt and, for whatever reason, that string's <number> is <= 0.

                  • Comment out all your own stylesheet directives wherever they are. Does that solve?
                  • Check the string being passed into setHtml(QString const&). Does that have something like this, to do with a font size, in the HTML?
                  J Offline
                  J Offline
                  Jakob Clausen
                  wrote on last edited by
                  #9

                  @JonB
                  Hi again.
                  I think I have found the error. :-)
                  First I tried to comment out all my own stylesheet directives by commenting out all calls to setStyleSheet(). That did not work, the error was still there.
                  Then I looked at your second advise - try to look at the string passed to setHtml(). This was not possible through the stacktrace - it was grayed out, so I could not select it. Maybe I could put a breakpoint in it anyway?
                  But it turns out that I use html. I have the function richtext that returns a string, that I use in setText(). And richtext does set a fontsize in a html tag. So the solution is to only append the fontsize line, if the fontsize is larger than zero.
                  Does all this make sense?

                  QString Widget::richtext(QString data, int fontsize, QColor color)
                  {
                      QString text = TAG_BEGIN_START;
                      text += TAG_FONT_SIZE + QString::number(fontsize) + "pt;";
                      text += TAG_FONT_WEIGHT + QString::number(FONT_WEIGHT) + ";";
                      text += TAG_FONT_COLOR + color.name() + ";";
                      text += TAG_END_START;
                      text += data;
                      text += TAG_STOP;
                  
                      return text;
                  }
                  

                  Thank you very much for your time and help. :-)

                  JonBJ 1 Reply Last reply
                  0
                  • J Jakob Clausen

                    @JonB
                    Hi again.
                    I think I have found the error. :-)
                    First I tried to comment out all my own stylesheet directives by commenting out all calls to setStyleSheet(). That did not work, the error was still there.
                    Then I looked at your second advise - try to look at the string passed to setHtml(). This was not possible through the stacktrace - it was grayed out, so I could not select it. Maybe I could put a breakpoint in it anyway?
                    But it turns out that I use html. I have the function richtext that returns a string, that I use in setText(). And richtext does set a fontsize in a html tag. So the solution is to only append the fontsize line, if the fontsize is larger than zero.
                    Does all this make sense?

                    QString Widget::richtext(QString data, int fontsize, QColor color)
                    {
                        QString text = TAG_BEGIN_START;
                        text += TAG_FONT_SIZE + QString::number(fontsize) + "pt;";
                        text += TAG_FONT_WEIGHT + QString::number(FONT_WEIGHT) + ";";
                        text += TAG_FONT_COLOR + color.name() + ";";
                        text += TAG_END_START;
                        text += data;
                        text += TAG_STOP;
                    
                        return text;
                    }
                    

                    Thank you very much for your time and help. :-)

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #10

                    @Jakob-Clausen said in How to locate where the qt asserts happens:

                    QString::number(fontsize)`

                    Indeed you need to check fontsize > 0 here. If that is not true it would lead to your error.

                    J 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Jakob-Clausen said in How to locate where the qt asserts happens:

                      QString::number(fontsize)`

                      Indeed you need to check fontsize > 0 here. If that is not true it would lead to your error.

                      J Offline
                      J Offline
                      Jakob Clausen
                      wrote on last edited by
                      #11

                      @JonB Exactly.
                      Thank you very much. :-)

                      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