From b089427c211d1da017941489fc90f37cca2f2cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 18 Aug 2009 11:07:26 +0200 Subject: Fix a potential crash in AnchorVertex::toString(). Don't assume that m_item is always a QGraphicsWidget --- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index b6cef4e..be8e32f 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -106,15 +106,16 @@ inline QString AnchorVertex::toString() const edge = QLatin1String("None"); break; } - QString item; + QString itemName; if (m_item->isLayout()) { - item = QLatin1String("layout"); + itemName = QLatin1String("layout"); } else { - QGraphicsWidget *w = static_cast(m_item); - item = w->data(0).toString(); + if (QGraphicsItem *item = m_item->graphicsItem()) { + itemName = item->data(0).toString(); + } } edge.insert(0, QLatin1String("%1_")); - return edge.arg(item); + return edge.arg(itemName); } -- cgit v0.12