Results 1 to 17 of 17

Thread: Qt is crashing when showing this tooltip. Why?

  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt is crashing when showing this tooltip. Why?

    My Qt application keeps on crashing when the tooltip in the attached file is shown.


    To reproduce the problem just set a widget tooltip in the following way:

    Qt Code:
    1. QFile file("tooltip.txt");
    2. file.open(QIODevice::ReadOnly);
    3. QTextStream stream(&file);
    4. QString tooltipText = stream.readAll();
    5. file.close();
    6.  
    7. myWidget->setToolTip(tooltipText);
    To copy to clipboard, switch view to plain text mode 

    I'm using the latest version of Qt (4.6.3) on Windows
    I'm going to submit a bugreport, but in the meanwhile can anyone suggest me a solution to fix this crash problem?

    Thanks in advance for your help

    Update:
    I attached a simple project to reproduce the problem.
    I compile that project with Qt 4.6.3 and Visual Studio 2008 Express on Windows Xp
    In debug mode it crashes always when I move the mouse on top of the widget and the tooltip is shown. In relase mode sometimes it crashes sometimes not.

    Here is part of the call stack when it crashes:

    tGuid4.dll!`anonymous namespace'::LineBreakHelper::currentGlyph() Line 1683 + 0x1a bytes C++
    QtGuid4.dll!`anonymous namespace'::LineBreakHelper::adjustRightBearing() Line 1692 + 0xe bytes C++
    QtGuid4.dll!QTextLine::layout_helper(int maxGlyphs=2147483647) Line 1931 C++
    QtGuid4.dll!QTextLine::setLineWidth(double width=8388607.0000000000) Line 1602 C++
    QtGuid4.dll!qt_format_text(const QFont & fnt={...}, const QRectF & _r={...}, int tf=134218769, const QTextOption * option=0x00000000, const QString & str={...}, QRectF * brect=0x00000000, int tabstops=48, int * __formal=0x00000000, int tabarraylen=0, QPainter * painter=0x0012cb54) Line 7747 C++
    QtGuid4.dll!QPainter::drawText(const QRect & r={...}, int flags=1041, const QString & str={...}, QRect * br=0x00000000) Line 5807 + 0x41 bytes C++
    QtGuid4.dll!QStyle::drawItemText(QPainter * painter=0x0012cb54, const QRect & rect={...}, int alignment=1041, const QPalette & pal={...}, bool enabled=true, const QString & text={...}, QPalette::ColorRole textRole=ToolTipText) Line 541 C++
    QtGuid4.dll!QLabel:aintEvent(QPaintEvent * __formal=0x0012d3f0) Line 1038 C++
    QtGuid4.dll!QTipLabel:aintEvent(QPaintEvent * ev=0x0012d3f0) Line 230 C++
    QtGuid4.dll!QWidget::event(QEvent * event=0x0012d3f0) Line 8191 C++
    .....
    Attached Files Attached Files
    Last edited by kalos80; 26th July 2010 at 13:23.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt is crashing when showing this tooltip. Why?

    Have you checked the stream to see if the file is being read without error? Have you tried printing out the resulting string to see if it is what you expect?

  3. #3
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    Ok, I was try this example and I didn't have any problem. If my program see this file, then I can see a contents of this file as a tooltip. If my program doesn't see this file, then I see nothing as a tooltip.
    I have: MSVC 2008, Qt 4.6.2, Windows 7

  4. #4
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    This is just an example to reproduce the problem.

    In my application the error string is not read from a file. It is the result of the execution of some operations.
    I just saved that string in a file and then created a test application to reproduce the problem.

  5. #5
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    I think, that problem is not in a setToolTip function. Maybe your other code brings this error. If you try a simplest application, that just set a toolTip to a widget, you'll see, that it's true.

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    Please create a minimum compilable application that demonstrates the problem. If the error still occurs, then post that application.

  7. #7
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    I just updated the main post adding a very simple test project reproducing the problem.

    Please give it a try, the project is very simple, just create a widget and sets its tooltip to the guilty one.
    I compile that project with latest Qt version 4.6.3 on Windows Xp and Visual Studio 2008 Express Edition

    I submitted a bugreport for this problem.

    I would be really glad if I could find a workaround to this problem

  8. #8
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    Well I tested the application against the following styles:

    Windows
    WindowsXP
    Motif
    CDE
    Plastique
    Cleanlooks

    It crashes only with WindowsXP and Cleanlooks styles

  9. #9
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    I downloaded your project, compiled it and ran. When I move the mouse to widget I see a tooltip from file.
    Then I ask my colleague, that has Qt 4.6.3, to do the same, and it works OK on his computer. I and my colleague tried both Debug and Release configurations. It works fine. Try to reinstall Qt, Studio and, maybe, Windows

  10. #10
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qt is crashing when showing this tooltip. Why?

    I also tested it with QCleanlooksStyle and it worked fine. So there is probably something wrong with your environment.

    P.s.: You should only send a bug report if you are 99.9999999% that it is not related to any things on your special computer setup. Therefore you should setup a clean environment in a virtual box and test your errors there.

  11. #11
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: Qt is crashing when showing this tooltip. Why?

    I try to show the text from tooltip.txt using QMessageBox, and my application crashes. The error is similar to kalos80.

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. QFile file("tooltip.txt");
    6. if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    7. return 0;
    8.  
    9. QTextStream stream(&file);
    10.  
    11. QString str = stream.readAll();
    12. file.close();
    13.  
    14. QMessageBox::warning(0, "INFO", str);
    15.  
    16. return 0;
    17. }
    To copy to clipboard, switch view to plain text mode 

    Then i modify my code to this
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. QFile file("tooltip.txt");
    6. if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    7. return 0;
    8.  
    9. QTextStream stream(&file);
    10.  
    11. QString str = stream.readAll();
    12. qDebug() << str;
    13. file.close();
    14.  
    15. QMessageBox msgbox;
    16. msgbox.setTextFormat(Qt::RichText); // using Qt::AutoText or Qt::PlainText crashes too!
    17. msgbox.setText(str);
    18. msgbox.exec();
    19.  
    20. return 0;
    21. }
    To copy to clipboard, switch view to plain text mode 
    It works fine but the text missing some spaces and newlines.
    BTW, i use qt-sdk-win-opensource-2010.03.

  12. #12
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    I'm happy that someone else could reproduce the problem.

    Also if I call simplified() function on the tooltip string, there is no crash, but I lose the original text formatting

  13. #13
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: Qt is crashing when showing this tooltip. Why?

    Maybe adding the following code will fix your problems

    Qt Code:
    1. tooltipText.prepend("<pre>");
    2. tooltipText.append("</pre>");
    3.  
    4. myWidget->setToolTip(tooltipText);
    To copy to clipboard, switch view to plain text mode 

    The text formatting is ok, but not the font.

  14. #14
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    saa7_go,

    yes your solution seems to work.
    I wonder wether this works in all cases or there could still be some tooltips that could cause my application to crash.

    I can use it as a temporary solution, waiting for a fix to such bug.

  15. #15
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qt is crashing when showing this tooltip. Why?

    Have you tried with an other (simple) text file? Because it might be that in the text file something went wrong with the encoding.

  16. #16
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Qt is crashing when showing this tooltip. Why?

    On my machine your app crashes because of consecutive ASCII tab (0x09) and LF (0x0A) characters after "...XYrange,recn,mode)" in tooltip.txt.

    Is that combination of control characters significant? I Goolged a bit but didn't find anything.

    I even get a crash with the attached simple file.
    Attached Files Attached Files

  17. The following user says thank you to norobro for this useful post:

    kalos80 (27th July 2010)

  18. #17
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt is crashing when showing this tooltip. Why?

    norobro, it seems you found the cause of the crash:
    a tab followed by the line feed character.

    I will change my code trying to avoid that sequence of characters.
    In any case, I still think I can show anything on a tooltip and it should not crash.

    I will add your hints to the bugreport, clearly mentioning you.

Similar Threads

  1. Application crashing
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 22nd May 2009, 10:37
  2. Crashing without qDebug() ?
    By xtreme in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2008, 17:01
  3. QMultiHash - crashing
    By steg90 in forum Qt Programming
    Replies: 16
    Last Post: 23rd May 2007, 13:18
  4. Showing QMainWindow without showing a child QWidget
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 09:03
  5. Application is Crashing
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 17:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.