summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-12-06 18:24:29 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-06 09:35:09 -0800
commitbfe5ccda1ca50221828255e8f017a5f0180a020a (patch)
tree690dc27ea4896dd89443780213698e1e86727ab7 /qt-ui
parent8f58faf43110ec83e991243bbecdb1883c1b126b (diff)
downloadsubsurface-bfe5ccda1ca50221828255e8f017a5f0180a020a.tar.gz
Print: add a safe-guard if table print rows are too big
We do not support rows larger than a single page as the PrintLayout algorithm will enter an infinite loop, therefore we put a limit of 15 lines for the location text. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/models.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 6a1e007b7..9950ed339 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1536,7 +1536,23 @@ bool TablePrintModel::setData(const QModelIndex &index, const QVariant &value, i
case 3: list.at(index.row())->duration = value.toString();
case 4: list.at(index.row())->divemaster = value.toString();
case 5: list.at(index.row())->buddy = value.toString();
- case 6: list.at(index.row())->location = value.toString();
+ case 6: {
+ /* truncate if there are more than N lines of text,
+ * we don't want a row to be larger that a single page! */
+ QString s = value.toString();
+ const int maxLines = 15;
+ int count = 0;
+ for (int i = 0; i < s.length(); i++) {
+ if (s.at(i) != QChar('\n'))
+ continue;
+ count++;
+ if (count > maxLines) {
+ s = s.left(i - 1);
+ break;
+ }
+ }
+ list.at(index.row())->location = s;
+ }
}
return true;
}