Closed ojura closed 2 years ago
Hey @SeriousAlexej, thanks for merging it so quickly :)
Unfortunately I afterwards realized there is a problem with this approach. Constructing a QProxyStyle from a QStyle* steals the ownership of the style object. In this case, from QApplication, so that’s not good.
Maybe we can have a single TTToolButtonStyle instance which would be used for all widgets in the ribbon, and then if the user is using a custom style, they can pass a new copy of their style to TabRibbon which TTToolButtonStyle can then take the ownership of, since unfortunately we can’t safely make a copy of qApp->style().
Well that was unfortunate :D I dont have much free time till weekend so I guess it will be like that for a while. Cant evaluate the impact until then either, so if you think it might be better to revert PR for a while, please tell so.
Yes, for now I think it's best to revert.
It looks like QProxyStyle
always steals the ownership of the passed QStyle*
, while constructing it with nullptr
will result in the native style being used.
So, it looks like the only proper solution is to enable the TabToolbar users to pass a copy of the same style they have set for qApp->style()
which we can safely take the ownership of.
One other note - when you call QWidget::setStyle
for the tool buttons, it doesn't take ownership, so you're actually leaking TTToolButtonStyle
objects now! Ensuring there is only a single instance of TTToolButtonStyle
would fix this.
It looks like
QProxyStyle
uses the native OS style, even if we override it in the rest of the app by setting a globalQApplication
style.This makes
TTToolButtonStyle
respect the globalQApplication
style.