From 59b6ad6a0ba3527b73f008a94defe4aa57add5f6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 24 Mar 2020 09:01:24 +0100 Subject: divelist: don't initialize invalidFont at startup To mark invalid dives, we use a struck-out font, which was a static variable at translation unit scope, i.e. initialized at application startup. Sadly, this crashes on iOS. It is unclear when we can initialize fonts. Try to move initialization to the constructore of DiveTripModelBase and make the font a member of that class. For consistency, also make the invalidBrush a member of this class. This now means that the diveData function cannot be static anymore, since it needs access to the font and brush. But OK. Reported-by: Dirk Hohndel Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'qt-models/divetripmodel.cpp') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index bcca977b5..207962906 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -190,16 +190,7 @@ static QString displayWeight(const struct dive *d, bool units) return s + gettextFromC::tr("lbs"); } -static QFont struckOutFont() -{ - QFont font; - font.setStrikeOut(true); - return font; -} -static QBrush invalidForeground(Qt::gray); -static QFont invalidFont = struckOutFont(); - -QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role) +QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role) const { #ifdef SUBSURFACE_MOBILE // Special roles for mobile @@ -509,8 +500,10 @@ void DiveTripModelBase::reset() emit diveListNotifier.numShownChanged(); } -DiveTripModelBase::DiveTripModelBase(QObject *parent) : QAbstractItemModel(parent) +DiveTripModelBase::DiveTripModelBase(QObject *parent) : QAbstractItemModel(parent), + invalidForeground(Qt::gray) { + invalidFont.setStrikeOut(true); } int DiveTripModelBase::columnCount(const QModelIndex&) const -- cgit v1.2.3-70-g09d2