diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-08-18 09:07:26 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-08-18 09:07:26 (GMT) |
commit | b089427c211d1da017941489fc90f37cca2f2cc8 (patch) | |
tree | 525fde3b1c2437c7aea124d2195b0221fea013e8 | |
parent | a5a925748ff3893e4acf2d41bd8aee0d11a3285a (diff) | |
download | Qt-b089427c211d1da017941489fc90f37cca2f2cc8.zip Qt-b089427c211d1da017941489fc90f37cca2f2cc8.tar.gz Qt-b089427c211d1da017941489fc90f37cca2f2cc8.tar.bz2 |
Fix a potential crash in AnchorVertex::toString().
Don't assume that m_item is always a QGraphicsWidget
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.h | 11 |
1 files 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<QGraphicsWidget *>(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); } |