aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2019-11-27 10:50:19 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2019-11-27 11:15:19 +0100
commit0b7358d2d24cc93160f77bac7b210cf83d404c5b (patch)
treebb1af1dbb33f11bdc73af7357bf5450dd6c173e0
parentc64e050dee65a880d21163ffb480fd44725b2a14 (diff)
QQuickOverlay: use qobject_cast instead of static_cast
This mirrors the behavior of QQuickOverlayPrivate::addPopup While this might not be an issue in practice, as removeOne should fail nevertheless, this avoids a warning from UBSan and should have only a negligible performance impact. The warning appears for instance in the (otherwise unrelated) example from bug QTBUG-80070: qquickoverlay.cpp:258:63: runtime error: downcast of address 0x55d6e1b34860 which does not point to an object of type 'QQuickDrawer' 0x55d6e1b34860: note: object is of type 'QQuickPopup' Change-Id: Ic51979ad25e864151245b6d47c733696a099bde8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 3f358706..73a31c84 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -38,6 +38,7 @@
#include "qquickoverlay_p_p.h"
#include "qquickpopupitem_p_p.h"
#include "qquickpopup_p_p.h"
+#include "qquickdrawer_p.h"
#include "qquickdrawer_p_p.h"
#include "qquickapplicationwindow_p.h"
#include <QtQml/qqmlinfo.h>
@@ -255,7 +256,7 @@ void QQuickOverlayPrivate::removePopup(QQuickPopup *popup)
{
Q_Q(QQuickOverlay);
allPopups.removeOne(popup);
- if (allDrawers.removeOne(static_cast<QQuickDrawer *>(popup)))
+ if (allDrawers.removeOne(qobject_cast<QQuickDrawer *>(popup)))
q->setVisible(!allDrawers.isEmpty() || !q->childItems().isEmpty());
}