summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Whiting <[email protected]>2015-04-30 22:46:14 -0600
committerJeremy Whiting <[email protected]>2015-04-30 22:46:14 -0600
commit9ecef2f11150eec55b52314400ac204f506ef25c (patch)
tree7ef5f7a96a4b261252644fff16ac4fa560f92ce1
parent0c68d601dfa4a6858fb418799eae1763c6d8841a (diff)
Guard against invalid pointers in PhraseBookDialog.
-rw-r--r--phrasebook/phrasebookdialog.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/phrasebook/phrasebookdialog.cpp b/phrasebook/phrasebookdialog.cpp
index c7d7835..6ef16f3 100644
--- a/phrasebook/phrasebookdialog.cpp
+++ b/phrasebook/phrasebookdialog.cpp
@@ -525,7 +525,7 @@ QModelIndex PhraseBookDialog::getCurrentParent()
{
QModelIndex currentIndex = m_ui->treeView->currentIndex();
QStandardItem *item = m_bookModel->itemFromIndex(currentIndex);
- if (!item->isDropEnabled()) // If it's not a book
+ if (item != NULL && !item->isDropEnabled()) // If it's not a book
currentIndex = currentIndex.parent();
return currentIndex;
}
@@ -547,7 +547,10 @@ void PhraseBookDialog::slotAddPhrasebook () {
QList<QStandardItem*> items;
items << item << shortcutItem;
- parent->appendRow(items);
+ if (parent)
+ parent->appendRow(items);
+ else
+ m_bookModel->appendRow(items);
focusNewItem(parentIndex, item);
}
@@ -562,7 +565,10 @@ void PhraseBookDialog::slotAddPhrase () {
QList<QStandardItem*> items;
items << item << shortcutItem;
- parent->appendRow(items);
+ if (parent)
+ parent->appendRow(items);
+ else
+ m_bookModel->appendRow(items);
focusNewItem(parentIndex, item);
}