From 3d4c6cfcf511cddb658b28b49fc3dacb4be2c8bf Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Thu, 12 Jul 2018 17:42:09 +0200 Subject: [PATCH] Add sanity check when loading table-header information This results in an error message instead of an assertion failure if the header configuration is invalid. --- lib/headerlist.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/headerlist.h b/lib/headerlist.h index 81c6f170..118e7c06 100644 --- a/lib/headerlist.h +++ b/lib/headerlist.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "db.h" #include "settings.h" @@ -142,9 +143,21 @@ class dbheader void fromData(QString s) { QStringList sl = s.split(" "); + if (sl.count() != 4) { + qCritical() << "Invalid header data for" << + id << name << s; + return; + } visualIndex = sl[0].toInt(); + if (visualIndex < -1) + visualIndex = -1; sortIndicator = sl[1].toInt(); + if (sortIndicator != Qt::AscendingOrder && + sortIndicator != Qt::DescendingOrder) + sortIndicator = -1; size = sl[2].toInt(); + if (size == 0) + size = -1; show = sl[3].toInt(); } void setupHeaderView(int sect, QHeaderView *hv)