aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-03-07 09:50:43 +0100
committerChristian Tismer <tismer@stackless.com>2017-03-08 09:35:13 +0000
commitf68388cf547c0d63a5d4a145f65aa9fa90529d52 (patch)
tree5d6b74066e61069358a3331114ab21252d079e69
parentd16479e20d8b0ad51c90c7600d316f119e36f66f (diff)
fix bogus setMargin in pyside2-uic
This bug has been reported five years ago. By inspecting uiparser.py, in function createLayout, an extra 'margin' element is added (~line 399) because the layout is child of a QWidget which is not the child of the main window. The code in that function checks if there are individual margin elements but fails in the case where there is a single 'margin' element, that is, when all margins are equal. If at least one margin is different then the problem doesn't appear. Task-number: PYSIDE-127 Change-Id: I557a12a15048c5c713badc44309e2bb2144a35a9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--pyside2uic/uiparser.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pyside2uic/uiparser.py b/pyside2uic/uiparser.py
index 0fd9481..da1d744 100644
--- a/pyside2uic/uiparser.py
+++ b/pyside2uic/uiparser.py
@@ -397,9 +397,11 @@ class UIParser(object):
SubElement(cme, 'number').text = str(right)
SubElement(cme, 'number').text = str(bottom)
elif self.layout_widget:
- # The layout's of layout widgets have no margin.
- me = SubElement(elem, 'property', name='margin')
- SubElement(me, 'number').text = '0'
+ margin = self.wprops.getProperty(elem, 'margin', -1)
+ if margin < 0:
+ # The layouts of layout widgets have no margin.
+ me = SubElement(elem, 'property', name='margin')
+ SubElement(me, 'number').text = '0'
# In case there are any nested layouts.
self.layout_widget = False