QPageLayout: do not calculate an invalid margin
A default constructed QPageLayout has an invalid QPageSize. When asking for its size, an invalid QSize is returned (-1, -1). This size is then used to calculate the maximum margins the page layout can have, resulting in negative margins. I'm not sure if that makes sense for QPageLayout (in principle, a negative margin is acceptable, meaning to "grow" the size), but then this margin is passed as an upper bound to a series of qBound calls in QPageLayoutPrivate::clampMargins. To fix this, change the calculations of the maximum margins by using a lower bound of 0. Change-Id: I429104acfb2296d9eb1ee54c113e9d7e22d9b6ab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
212b7614e1
commit
19072a177b
@ -231,10 +231,10 @@ QMargins QPageLayoutPrivate::marginsPixels(int resolution) const
|
||||
void QPageLayoutPrivate::setDefaultMargins(const QMarginsF &minMargins)
|
||||
{
|
||||
m_minMargins = minMargins;
|
||||
m_maxMargins = QMarginsF(m_fullSize.width() - m_minMargins.right(),
|
||||
m_fullSize.height() - m_minMargins.bottom(),
|
||||
m_fullSize.width() - m_minMargins.left(),
|
||||
m_fullSize.height() - m_minMargins.top());
|
||||
m_maxMargins = QMarginsF(qMax(m_fullSize.width() - m_minMargins.right(), qreal(0)),
|
||||
qMax(m_fullSize.height() - m_minMargins.bottom(), qreal(0)),
|
||||
qMax(m_fullSize.width() - m_minMargins.left(), qreal(0)),
|
||||
qMax(m_fullSize.height() - m_minMargins.top(), qreal(0)));
|
||||
if (m_mode == QPageLayout::StandardMode)
|
||||
clampMargins(m_margins);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user