dynamic_cast -> qobject_cast for QObjectDerived*

We cannot use dynamic_cast in Qt.

Change-Id: Ia6aeeb2439ca8c24239dce7cff55a0c18860e43e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Robin Burchell 2017-01-17 18:56:42 +01:00
parent 24d4e164ad
commit f64fb98a28
3 changed files with 8 additions and 8 deletions

View File

@ -98,10 +98,10 @@ void QSGSoftwareImageNode::paint(QPainter *painter)
if (!m_cachedPixmap.isNull()) {
painter->drawPixmap(m_rect, m_cachedPixmap, m_sourceRect);
} else if (QSGSoftwarePixmapTexture *pt = dynamic_cast<QSGSoftwarePixmapTexture *>(m_texture)) {
} else if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture *>(m_texture)) {
const QPixmap &pm = pt->pixmap();
painter->drawPixmap(m_rect, pm, m_sourceRect);
} else if (QSGPlainTexture *pt = dynamic_cast<QSGPlainTexture *>(m_texture)) {
} else if (QSGPlainTexture *pt = qobject_cast<QSGPlainTexture *>(m_texture)) {
const QImage &im = pt->image();
painter->drawImage(m_rect, im, m_sourceRect);
}
@ -113,14 +113,14 @@ void QSGSoftwareImageNode::updateCachedMirroredPixmap()
m_cachedPixmap = QPixmap();
} else {
if (QSGSoftwarePixmapTexture *pt = dynamic_cast<QSGSoftwarePixmapTexture *>(m_texture)) {
if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture *>(m_texture)) {
QTransform mirrorTransform;
if (m_transformMode.testFlag(MirrorVertically))
mirrorTransform = mirrorTransform.scale(1, -1);
if (m_transformMode.testFlag(MirrorHorizontally))
mirrorTransform = mirrorTransform.scale(-1, 1);
m_cachedPixmap = pt->pixmap().transformed(mirrorTransform);
} else if (QSGPlainTexture *pt = dynamic_cast<QSGPlainTexture *>(m_texture)) {
} else if (QSGPlainTexture *pt = qobject_cast<QSGPlainTexture *>(m_texture)) {
m_cachedPixmap = QPixmap::fromImage(pt->image().mirrored(m_transformMode.testFlag(MirrorHorizontally), m_transformMode.testFlag(MirrorVertically)));
} else {
m_cachedPixmap = QPixmap();

View File

@ -293,10 +293,10 @@ QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaqu
case QSGSoftwareRenderableNode::SimpleTexture:
{
QSGTexture *texture = m_handle.simpleTextureNode->texture();
if (QSGSoftwarePixmapTexture *pt = dynamic_cast<QSGSoftwarePixmapTexture *>(texture)) {
if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture *>(texture)) {
const QPixmap &pm = pt->pixmap();
painter->drawPixmap(m_handle.simpleTextureNode->rect(), pm, m_handle.simpleTextureNode->sourceRect());
} else if (QSGPlainTexture *pt = dynamic_cast<QSGPlainTexture *>(texture)) {
} else if (QSGPlainTexture *pt = qobject_cast<QSGPlainTexture *>(texture)) {
const QImage &im = pt->image();
painter->drawImage(m_handle.simpleTextureNode->rect(), im, m_handle.simpleTextureNode->sourceRect());
}

View File

@ -385,7 +385,7 @@ void tst_creation::bindings_qml()
return;
}
QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create());
QQuickItem *obj = qobject_cast<QQuickItem *>(component.create());
QVERIFY(obj != nullptr);
int height = 0;
@ -407,7 +407,7 @@ void tst_creation::bindings_parent_qml()
return;
}
QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create());
QQuickItem *obj = qobject_cast<QQuickItem *>(component.create());
QVERIFY(obj != nullptr);
int height = 0;