Results 1 to 5 of 5

Thread: QT 4.4.0 Upgrade QPainter Problem

  1. #1
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation QT 4.4.0 Upgrade QPainter Problem

    Hello all,

    I recently upgraded from QT 4.3.4 to 4.4.0. When I upgraded, my GUI started giving me an "ASSERT: SharedPainter ? SharedPainter->isActive() : true" error and then the program craps out.

    Here is the stack trace:

    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::begin: A paint device can only be painted by one painter at a time.
    QPainter::restore: Painter not active
    ASSERT: "sharedPainter ? sharedPainter->isActive() : true" in file kernel\qwidget.cpp, line 4398
    Anyone have any idea?

    Thanks,

    Chris
    Last edited by jpn; 13th May 2008 at 20:22. Reason: missing [quote] tags

  2. #2
    Join Date
    May 2008
    Location
    London, UK
    Posts
    8
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.4.0 Upgrade QPainter Problem

    ...

    Note sure what the problem is, but perhaps you have more than one painter trying to paint the same device at once?

    Sounds obvious, but are you calling QPainter::begin and QPainter::end correctly? If you're using the constructor instead of begin(), make sure the QPainter object is really being destroyed.

    Also, the output you posted isn't a stack trace - if you still can't work it out, posting a backtrace at the point of the assert might help debug the issue (I'm guessing that it'd lead you back to one of the conflicting QPainter objects anyway).

    HTH!

  3. The following user says thank you to thomir for this useful post:

    ChrisReath (13th May 2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT 4.4.0 Upgrade QPainter Problem

    Hey -- Tried your advice above and still got the same result. This is what the call stack looks like at the point of the Assert:

    QTCored4.dll!67037ad()
    QtCored4.dll!670375a1()

    and then nothing else. Strange indeed.

  5. #4
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT 4.4.0 Upgrade QPainter Problem

    Actually, you were absolutely right. You can only have one QPainter Object in existence at one time.

    If you use this method to create QPainter Objects:

    Qt Code:
    1. void MyWidget::paintEvent(QPaintEvent *)
    2. {
    3. QPainter p(this);
    4. p.drawLine(...); // drawing code
    5. }
    To copy to clipboard, switch view to plain text mode 
    You have to be careful because you can't use another QPainter p(this) object in the same function. So you are almost always better off using this method:

    Qt Code:
    1. void MyWidget::paintEvent(QPaintEvent *)
    2. {
    3. p.begin(this);
    4. p.drawLine(...); // drawing code
    5. p.end();
    6. }
    To copy to clipboard, switch view to plain text mode 

    to create QPainter objects so you can begin() and end() Painter Objects appropriately. Thanks for your help.

    Chris
    Last edited by jpn; 13th May 2008 at 20:22. Reason: missing [code] tags

  6. #5
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT 4.4.0 Upgrade QPainter Problem

    Also, for some reason, QT didn't bother with this assert error in 4.3.4, it is something new they added in 4.4.0 to protect the user.

Similar Threads

  1. Qpainter function on a QFrame problem
    By impeteperry in forum Newbie
    Replies: 45
    Last Post: 14th October 2008, 13:43
  2. Hi. I have problem with QCString in 4.4.0
    By ivi2501 in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2008, 19:30
  3. use Qpainter to draw lines + problem in my painter
    By ReSu in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2008, 16:44
  4. Qt 4.4.0 make problem
    By MarkoSan in forum Installation and Deployment
    Replies: 24
    Last Post: 22nd January 2008, 18:58
  5. qpainter "drawText() problem
    By impeteperry in forum Qt Programming
    Replies: 10
    Last Post: 25th March 2007, 01:46

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.