[Qt-interest] Widget does not update content after some time

Damien R damien.rg at gmail.com
Tue Oct 20 18:38:22 CEST 2009


> Seeing two locks, I bet you have deadlock situation -- you've already
> acquired the lock in setImage(), then you invoke update. However, you
> still hold the lock. What happens if update() calls your paintEvent()
> method for the same object? You attempt to lock again, but you already
> hold the mutex. Deadlock.

No, it is not a deadlock. update() add an event in the process event list of
Qt so update() do not directly call paintEvent() as I understand the
documentation of Qt. So this code is never equivalent to the following code
:
void setImage(std::size_t i)
{
  boost::mutex::scoped_lock lock(mutex_);
  uchar * imageBuffer = image.bits();
  memset(imageBuffer, i * 25 % 255, WIDTH * HEIGHT * 3);
  paintEvent(0);
}

Moreover, the program is not frozen. Indeed, if I hide the widget and show
it again, the content of the widget is updated.

--
Damien R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091020/b1f510ce/attachment.html 


More information about the Qt-interest-old mailing list