From a92cabf898f260f94a3a2ca2929b51a5c09a1cac Mon Sep 17 00:00:00 2001 From: jghali Date: Sat, 1 Sep 2012 13:29:59 +0000 Subject: 11057: Crash in character palette git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17769 11d20701-8431-0410-a711-e3c959e3b870 --- scribus/chartableview.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'scribus/chartableview.cpp') 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() -- cgit