QPlatformWindow: Extract static method for closestAcceptableGeometry().
On Windows, some messages occur before a QPlatformWindow is actually created, for example WM_WINDOWPOSCHANGING, which is handled in QWindowsWindow::handleGeometryChangingMessage(). Extract a static function QPlatformWindow::closestAcceptableGeometry() from QPlatformWindow::windowClosestAcceptableGeometry() and use that in QWindowsWindow::handleGeometryChangingMessage(). This fixes a regression crash occurring in Qt 5.6 when running the example from QTBUG-48201. Task-number: QTBUG-36220 Task-number: QTBUG-48201 Task-number: QTBUG-46615 Change-Id: I86b8f923447c8e447382427cf5795628ef1c9717 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
2978caa2ed
commit
42c6ea4f6c
@ -702,15 +702,20 @@ QRect QPlatformWindow::windowFrameGeometry() const
|
||||
a resize/move event for platforms that support it, for example to
|
||||
implement heightForWidth().
|
||||
*/
|
||||
QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const
|
||||
|
||||
QRectF QPlatformWindow::closestAcceptableGeometry(const QWindow *qWindow, const QRectF &nativeRect)
|
||||
{
|
||||
QWindow *qWindow = window();
|
||||
const QRectF rectF = QHighDpi::fromNativePixels(nativeRect, qWindow);
|
||||
const QRectF correctedGeometryF = qt_window_private(qWindow)->closestAcceptableGeometry(rectF);
|
||||
const QRectF correctedGeometryF = qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF);
|
||||
return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF
|
||||
? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
|
||||
}
|
||||
|
||||
QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const
|
||||
{
|
||||
return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QPlatformWindow
|
||||
\since 4.8
|
||||
|
@ -140,6 +140,7 @@ public:
|
||||
QRect windowGeometry() const;
|
||||
QRect windowFrameGeometry() const;
|
||||
QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const;
|
||||
static QRectF closestAcceptableGeometry(const QWindow *w, const QRectF &nativeRect);
|
||||
|
||||
protected:
|
||||
static QString formatWindowTitle(const QString &title, const QString &separator);
|
||||
|
@ -1825,7 +1825,7 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
|
||||
const QRect suggestedFrameGeometry(windowPos->x, windowPos->y,
|
||||
windowPos->cx, windowPos->cy);
|
||||
const QRect suggestedGeometry = suggestedFrameGeometry - margins;
|
||||
const QRectF correctedGeometryF = qWindow->handle()->windowClosestAcceptableGeometry(suggestedGeometry);
|
||||
const QRectF correctedGeometryF = QPlatformWindow::closestAcceptableGeometry(qWindow, suggestedGeometry);
|
||||
if (!correctedGeometryF.isValid())
|
||||
return false;
|
||||
const QRect correctedFrameGeometry = correctedGeometryF.toRect() + margins;
|
||||
|
Loading…
Reference in New Issue
Block a user