diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-26 05:58:59 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-26 05:58:59 -0400 |
commit | 4e37fec92b11f6b8d4bef068393ff8a84bde5662 (patch) | |
tree | c492b894fa3f81b4fae34dad34b65e2ec34ee004 /sigtools | |
parent | 649b1299e75633ca4d70424181ebd39b08967fb8 (diff) | |
download | sigen-4e37fec92b11f6b8d4bef068393ff8a84bde5662.tar.gz sigen-4e37fec92b11f6b8d4bef068393ff8a84bde5662.tar.xz sigen-4e37fec92b11f6b8d4bef068393ff8a84bde5662.zip |
Make it safer to get the name and type from the tree
Diffstat (limited to 'sigtools')
-rw-r--r-- | sigtools/PluginTree.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sigtools/PluginTree.cpp b/sigtools/PluginTree.cpp index 9dbc4376..38e9d2f7 100644 --- a/sigtools/PluginTree.cpp +++ b/sigtools/PluginTree.cpp @@ -48,12 +48,18 @@ PluginTree::PluginTree(const QStringList& types, QWidget* parent) : QString PluginTree::currentType() const { - return static_cast<PluginTreeModel::ClassData*>(d->m_view->currentIndex().internalPointer())->m_type; + QModelIndex index = d->m_view->currentIndex(); + if (!index.isValid()) + return QString(); + return static_cast<PluginTreeModel::ClassData*>(index.internalPointer())->m_type; } QString PluginTree::currentName() const { - return static_cast<PluginTreeModel::ClassData*>(d->m_view->currentIndex().internalPointer())->m_name; + QModelIndex index = d->m_view->currentIndex(); + if (!index.isValid()) + return QString(); + return static_cast<PluginTreeModel::ClassData*>(index.internalPointer())->m_name; } PluginTree::Private::Private(const QStringList& types, PluginTree* tree) : |