aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktooltip.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-15 16:51:41 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-18 09:53:53 +0000
commita5b14886968ad258921aeb719710744d99d0a464 (patch)
treefe547c96adba629ad2892aa109762f5f91855ca6 /src/quicktemplates2/qquicktooltip.cpp
parent11933cbeca4ce1cd47e790644dc522db227d4b8e (diff)
ToolTip: don't leak memory if attached to a non-Item
Previously, it was casting the attachee object to an item and passing it as a parent to the QObject constructor. When attached to a non-Item, it passed a null pointer as a parent. Change-Id: I45933e39e3080ab8e010fa3f7257fdffce4db685 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktooltip.cpp')
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 42ae8edd..6b51de95 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -245,11 +245,7 @@ void QQuickToolTip::setTimeout(int timeout)
QQuickToolTipAttached *QQuickToolTip::qmlAttachedProperties(QObject *object)
{
- QQuickItem *item = qobject_cast<QQuickItem *>(object);
- if (!item)
- qmlInfo(object) << "ToolTip must be attached to an Item";
-
- return new QQuickToolTipAttached(item);
+ return new QQuickToolTipAttached(object);
}
void QQuickToolTip::open()
@@ -341,9 +337,12 @@ QQuickToolTip *QQuickToolTipAttachedPrivate::instance(bool create) const
return tip;
}
-QQuickToolTipAttached::QQuickToolTipAttached(QQuickItem *item) :
- QObject(*(new QQuickToolTipAttachedPrivate), item)
+QQuickToolTipAttached::QQuickToolTipAttached(QObject *parent) :
+ QObject(*(new QQuickToolTipAttachedPrivate), parent)
{
+ QQuickItem *item = qobject_cast<QQuickItem *>(parent);
+ if (!item && parent)
+ qmlInfo(parent) << "ToolTip must be attached to an Item";
}
/*!