diff options
author | jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870> | 2012-09-01 13:29:59 +0000 |
---|---|---|
committer | jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870> | 2012-09-01 13:29:59 +0000 |
commit | a92cabf898f260f94a3a2ca2929b51a5c09a1cac (patch) | |
tree | 57daceb3962c6b710982a6b25c91b87ea0bc410c | |
parent | 8ca31efe42a530497a710b6d89b670527da02322 (diff) | |
download | scribus-a92cabf898f260f94a3a2ca2929b51a5c09a1cac.tar.gz scribus-a92cabf898f260f94a3a2ca2929b51a5c09a1cac.tar.xz scribus-a92cabf898f260f94a3a2ca2929b51a5c09a1cac.zip |
11057: Crash in character palette
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17769 11d20701-8431-0410-a711-e3c959e3b870
-rw-r--r-- | scribus/chartableview.cpp | 18 | ||||
-rw-r--r-- | scribus/chartableview.h | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/scribus/chartableview.cpp b/scribus/chartableview.cpp index 94497bf..8b559bc 100644 --- a/scribus/chartableview.cpp +++ b/scribus/chartableview.cpp @@ -63,7 +63,7 @@ void CharTableView::keyPressEvent(QKeyEvent *k) emit delChar(); break; case Qt::Key_Insert: - // safely emit selectChar(model()->characters()[currenCharactersIndex()]); + // safely emit selectChar(model()->characters()[currentCharactersIndex()]); viewDoubleClicked(QModelIndex()); break; } @@ -74,7 +74,9 @@ void CharTableView::mousePressEvent(QMouseEvent* e) { QTableView::mousePressEvent(e); - int index = currenCharactersIndex(); + int index = currentCharactersIndex(); + if (index < 0) + return; int currentChar = -1; if ((index < model()->characters().count()) && (model()->characters().count() > 0)) @@ -116,13 +118,17 @@ void CharTableView::mouseReleaseEvent(QMouseEvent* e) void CharTableView::viewDoubleClicked(const QModelIndex & /*index*/) { - if (model()->characters().count() > currenCharactersIndex()) - emit selectChar(model()->characters()[currenCharactersIndex()], model()->fonts()[currenCharactersIndex()]); + int charIndex = currentCharactersIndex(); + if (model()->characters().count() > charIndex) + emit selectChar(model()->characters()[charIndex], model()->fonts()[charIndex]); } -int CharTableView::currenCharactersIndex() +int CharTableView::currentCharactersIndex() { - return currentIndex().row() * model()->columnCount() + currentIndex().column(); + QModelIndex index = currentIndex(); + if (!index.isValid()) + return -1; + return index.row() * model()->columnCount() + index.column(); } void CharTableView::hideZoomedChar() diff --git a/scribus/chartableview.h b/scribus/chartableview.h index 1be1eb3..e35ca23 100644 --- a/scribus/chartableview.h +++ b/scribus/chartableview.h @@ -56,7 +56,7 @@ protected: void mouseMoveEvent(QMouseEvent* e); //! \brief Map current QModelIndex into CharClassDef index/position - int currenCharactersIndex(); + int currentCharactersIndex(); void hideZoomedChar(); |