[vlc-devel] [PATCH 3/4] Qt: refactor vout resize

Анатолий Аниськович lin.aaa.lin at gmail.com
Mon Aug 8 22:04:31 CEST 2016

2016-08-07 17:01 GMT+03:00 Jean-Baptiste Kempf <jb at videolan.org>:
> But the parent layout does not provide correct size! That's the point!
> Qt lies about the size().
> And you remove comments about clearly explained bugs!

You're wrong. This bug neither specific to Qt nor how it manage
windows under different OS. The bug was in code, VLC code. Qt was not
lying, it just reported size we've set. Why it was reporting wrong
size? Because of double resize. Qt won't recalculate geometry if
widget resized to the same size *twice*.

Let's trace not patched code:

* call to VideoWidget::setSize(w, h)
* previous code call resize(w, h) here

Geometry recalculated, everything *seems* OK, next:

* sizeChanged(w, h) emitted
* sizeChanged connected to MainInterface::videoSizeChanged(w, h),
videoSizeChanged calls resizeStack(w, h)
* resizeStack calls resize() of the main window. Math done in
resizeStack cause videoWidget to have the same size as it was before.
Children of QStackedWidget will receive width of the smallest child,
or w.

It's still OK, nothing looks wrong, but behold the clusterfuck:

* call to VideoWidget::setSize(w, h); w and h is the same as the first call
* previous code call resize(w, h) here

Widget got resized to w and h, as we asked.

* sizeChanged(w, h) emitted
* ...
* resizeStack calls resize()

And here when QStackedWidget says "Fuck You". It's size not changed
since previous resize, so no geometry recalculations for you. Since
there was no geometry recalculations, VideoWidget won't be resized
too, it will remain of size it was set in setSize(). And that's the
reason video was not centered.

To sum it up:
1) all that struggle and workarounds was because VideoWidget resized itself
2) this bug affect only vout of size less than main interface size.

More information about the vlc-devel mailing list