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:
Quote:
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
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!
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.
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:
Code:
{
p.drawLine(...); // drawing code
}
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:
Code:
{
p.begin(this);
p.drawLine(...); // drawing code
p.end();
}
to create QPainter objects so you can begin() and end() Painter Objects appropriately. Thanks for your help.
Chris
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.