diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-07-07 14:34:22 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-07-07 13:42:51 +0000 |
commit | 8bc2feb498cbbeafe0de52cda929ef7a881c0351 (patch) | |
tree | d239e3edffff77a79252fb9fcd2679f0a532c362 /src | |
parent | cca6e8e3bd80824ff5aa3e17995a5b46ad48be28 (diff) |
Drawer: ignore and warn about invalid edge values
This fixes an issue where an application would crash when opening a
drawer by dragging it after an invalid edge value had been set.
Task-number: QTBUG-61843
Change-Id: Ie9b9ea0276b356b92927b858f2be355bfc042afb
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 25 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdrawer_p_p.h | 2 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 66c84ea2..20279b03 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -40,6 +40,7 @@ #include <QtGui/qstylehints.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickwindow_p.h> #include <QtQuick/private/qquickanimation_p.h> #include <QtQuick/private/qquicktransition_p.h> @@ -530,20 +531,32 @@ bool QQuickDrawerPrivate::prepareExitTransition() return QQuickPopupPrivate::prepareExitTransition(); } -void QQuickDrawerPrivate::setEdge(Qt::Edge e) +bool QQuickDrawerPrivate::setEdge(Qt::Edge e) { - edge = e; - if (edge == Qt::LeftEdge || edge == Qt::RightEdge) { + Q_Q(QQuickDrawer); + switch (e) { + case Qt::LeftEdge: + case Qt::RightEdge: allowVerticalMove = true; allowVerticalResize = true; allowHorizontalMove = false; allowHorizontalResize = false; - } else { + break; + case Qt::TopEdge: + case Qt::BottomEdge: allowVerticalMove = false; allowVerticalResize = false; allowHorizontalMove = true; allowHorizontalResize = true; + break; + default: + qmlWarning(q) << "invalid edge value - valid values are: " + << "Qt.TopEdge, Qt.LeftEdge, Qt.RightEdge, Qt.BottomEdge"; + return false; } + + edge = e; + return true; } QQuickDrawer::QQuickDrawer(QObject *parent) @@ -578,7 +591,9 @@ void QQuickDrawer::setEdge(Qt::Edge edge) if (d->edge == edge) return; - d->setEdge(edge); + if (!d->setEdge(edge)) + return; + if (isComponentComplete()) d->reposition(); emit edgeChanged(); diff --git a/src/quicktemplates2/qquickdrawer_p_p.h b/src/quicktemplates2/qquickdrawer_p_p.h index 8547bce5..6ed62cf5 100644 --- a/src/quicktemplates2/qquickdrawer_p_p.h +++ b/src/quicktemplates2/qquickdrawer_p_p.h @@ -86,7 +86,7 @@ public: bool prepareEnterTransition() override; bool prepareExitTransition() override; - void setEdge(Qt::Edge edge); + bool setEdge(Qt::Edge edge); Qt::Edge edge; qreal offset; |