From f97c8d40c3eafa4360d6c2e51978c8de551e809a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 12 Dec 2012 12:55:21 +0100 Subject: De-inline all setters in QWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we don't do this, we can have binary compatibility issues later. For example https://codereview.qt-project.org/#change,41700 will change the behavior of setWidth and setHeight to call setSize instead of setGeometry, because we don't want changing the height to also set the position of a window; if x and y are left uninitialized it needs to remember that fact. But if setWidth is left as an inline method, calling setGeometry, then an application which was built with 5.0 would behave differently than an application built with 5.1, even if Qt is upgraded after the application was built. To generalize, setters should never be inlined. Change-Id: I1ec42cb61a45fe541b3f3bb99d1b1ca24ad2a517 Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 118 +++++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 46 deletions(-) (limited to 'src/gui/kernel/qwindow.cpp') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b1fd2d3f6b..68687577b3 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -934,11 +934,59 @@ void QWindow::setMinimumSize(const QSize &size) emit minimumHeightChanged(d->minimumSize.height()); } +/*! + \property QWindow::x + \brief the x position of the window's geometry +*/ +void QWindow::setX(int arg) +{ + if (x() != arg) + setGeometry(QRect(arg, y(), width(), height())); +} + +/*! + \property QWindow::y + \brief the y position of the window's geometry +*/ +void QWindow::setY(int arg) +{ + if (y() != arg) + setGeometry(QRect(x(), arg, width(), height())); +} + +/*! + \property QWindow::width + \brief the width of the window's geometry +*/ +void QWindow::setWidth(int arg) +{ + if (width() != arg) + setGeometry(QRect(x(), y(), arg, height())); +} + +/*! + \property QWindow::height + \brief the height of the window's geometry +*/ +void QWindow::setHeight(int arg) +{ + if (height() != arg) + setGeometry(QRect(x(), y(), width(), arg)); +} + +/*! + \property QWindow::minimumWidth + \brief the minimum width of the window's geometry +*/ void QWindow::setMinimumWidth(int w) { setMinimumSize(QSize(w, minimumHeight())); } +/*! + \property QWindow::minimumHeight + \brief the minimum height of the window's geometry +*/ void QWindow::setMinimumHeight(int h) { setMinimumSize(QSize(minimumWidth(), h)); @@ -967,11 +1015,19 @@ void QWindow::setMaximumSize(const QSize &size) emit maximumHeightChanged(d->maximumSize.height()); } +/*! + \property QWindow::maximumWidth + \brief the maximum width of the window's geometry +*/ void QWindow::setMaximumWidth(int w) { setMaximumSize(QSize(w, maximumHeight())); } +/*! + \property QWindow::maximumHeight + \brief the maximum height of the window's geometry +*/ void QWindow::setMaximumHeight(int h) { setMaximumSize(QSize(maximumWidth(), h)); @@ -1020,13 +1076,15 @@ void QWindow::setSizeIncrement(const QSize &size) } /*! - \fn void QWindow::setGeometry(int posx, int posy, int w, int h) - Sets the geometry of the window, excluding its window frame, to a rectangle constructed from \a posx, \a posy, \a w and \a h. \sa geometry() */ +void QWindow::setGeometry(int posx, int posy, int w, int h) +{ + setGeometry(QRect(posx, posy, w, h)); +} /*! \brief Sets the geometry of the window, excluding its window frame, to \a rect. @@ -1057,46 +1115,6 @@ void QWindow::setGeometry(const QRect &rect) emit heightChanged(rect.height()); } -/*! - \property QWindow::x - \brief the x position of the window's geometry -*/ - -/*! - \property QWindow::y - \brief the y position of the window's geometry -*/ - -/*! - \property QWindow::width - \brief the width of the window's geometry -*/ - -/*! - \property QWindow::height - \brief the height of the window's geometry -*/ - -/*! - \property QWindow::minimumWidth - \brief the minimum width of the window's geometry -*/ - -/*! - \property QWindow::minimumHeight - \brief the minimum height of the window's geometry -*/ - -/*! - \property QWindow::maximumWidth - \brief the maximum width of the window's geometry -*/ - -/*! - \property QWindow::maximumHeight - \brief the maximum height of the window's geometry -*/ - /*! Returns the geometry of the window, excluding its window frame. @@ -1172,18 +1190,24 @@ void QWindow::setFramePosition(const QPoint &point) } /*! - \fn void QWindow::setPosition(const QPoint &pt) \brief set the position of the window on the desktop to \a pt \sa position() */ +void QWindow::setPosition(const QPoint &pt) +{ + setGeometry(QRect(pt, size())); +} /*! - \fn void QWindow::setPosition(int posx, int posy) \brief set the position of the window on the desktop to \a posx, \a posy \sa position() */ +void QWindow::setPosition(int posx, int posy) +{ + setPosition(QPoint(posx, posy)); +} /*! \fn QPoint QWindow::position() const @@ -1200,13 +1224,15 @@ void QWindow::setFramePosition(const QPoint &point) */ /*! - \fn void QWindow::resize(int w, int h) - set the size of the window, excluding any window frame, to a QSize constructed from width \a w and height \a h \sa size(), geometry() */ +void QWindow::resize(int w, int h) +{ + resize(QSize(w, h)); +} /*! \brief set the size of the window, excluding any window frame, to \a newSize -- cgit v1.2.3