r17770 by jghali - #11057: Crash in character palette
scribus-commit
scribus-commit at lists.scribus.net
Sat Sep 1 13:31:12 UTC 2012
Author: jghali
Date: Sat Sep 1 13:31:11 2012
New Revision: 17770
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17770
Log:
#11057: Crash in character palette
Modified:
trunk/Scribus/scribus/chartableview.cpp
trunk/Scribus/scribus/chartableview.h
Modified: trunk/Scribus/scribus/chartableview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17770&path=/trunk/Scribus/scribus/chartableview.cpp
==============================================================================
--- trunk/Scribus/scribus/chartableview.cpp (original)
+++ trunk/Scribus/scribus/chartableview.cpp Sat Sep 1 13:31:11 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: trunk/Scribus/scribus/chartableview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17770&path=/trunk/Scribus/scribus/chartableview.h
==============================================================================
--- trunk/Scribus/scribus/chartableview.h (original)
+++ trunk/Scribus/scribus/chartableview.h Sat Sep 1 13:31:11 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