Bug 378313

Summary: Remove QTLayout warning from startup logs (Patch)
Product: [Applications] krita Reporter: Bruno P. Kinoshita <brunodepaulak>
Component: GeneralAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: minor Keywords: junior-jobs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Patch

Description Bruno P. Kinoshita 2017-03-31 11:07:58 UTC
Created attachment 104830 [details]
Patch

Hi, for a while I noticed the following message in my console when starting Krita:

    QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

Today while testing the appimage for 3.1.3-alpha-2 I decided to check why that was happening.

Learned that when you create a Layout passing a widget via constructor, it then sets itself as the main layout for that widget. Then debugging the Docker factory creation loop, found that the HistoryDocker was being created with a QVBoxLayout(this) and QHBoxLayout(this). So the second time a layout was created, the warning was raised.

Spent some time searching the web for example on how people create widgets with V+H box layouts, and the general consensus seems to create the horizontal passing nothing in the constructor, then the vertical with the widget in the constructor, and finally add the hboxlayout to the vboxlayout (e.g. http://zetcode.com/gui/qt4/layoutmanagement/).

Attached a patch created against the latest commit to the master branch.

Testing locally, the behaviour of the History Docker seemed to be the same (both H + V scroll bars working, can successfully go back and forth in history, etc).

Hope that helps!
Bruno
Comment 1 Halla Rempt 2017-03-31 14:43:46 UTC
Git commit 1d2343c0cacfb0b105fbe86c2bcef975a09b1041 by Boudewijn Rempt.
Committed on 31/03/2017 at 14:38.
Pushed by rempt into branch 'master'.

Patch by  Bruno P. Kinoshita, Thanks!

M  +2    -1    plugins/dockers/historydocker/HistoryDock.cpp

https://commits.kde.org/krita/1d2343c0cacfb0b105fbe86c2bcef975a09b1041