r17769 by jghali - 11057: Crash in character palette

scribus-commit scribus-commit at lists.scribus.net
Sat Sep 1 13:30:00 UTC 2012


Author: jghali
Date: Sat Sep  1 13:29:59 2012
New Revision: 17769

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17769
Log:
11057: Crash in character palette

Modified:
    branches/Version14x/Scribus/scribus/chartableview.cpp
    branches/Version14x/Scribus/scribus/chartableview.h

Modified: branches/Version14x/Scribus/scribus/chartableview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17769&path=/branches/Version14x/Scribus/scribus/chartableview.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/chartableview.cpp (original)
+++ branches/Version14x/Scribus/scribus/chartableview.cpp Sat Sep  1 13:29:59 2012
@@ -63,7 +63,7 @@
 		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 @@
 {
 	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::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()

Modified: branches/Version14x/Scribus/scribus/chartableview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17769&path=/branches/Version14x/Scribus/scribus/chartableview.h
==============================================================================
--- branches/Version14x/Scribus/scribus/chartableview.h (original)
+++ branches/Version14x/Scribus/scribus/chartableview.h Sat Sep  1 13:29:59 2012
@@ -56,7 +56,7 @@
 	void mouseMoveEvent(QMouseEvent* e);
 
 	//! \brief Map current QModelIndex into CharClassDef index/position
-	int currenCharactersIndex();
+	int currentCharactersIndex();
 
 	void hideZoomedChar();
 




More information about the scribus-commit mailing list