From dce3869339563c31e6c6fdf267e803eca4d134ea Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 26 Dec 2015 21:24:29 -0800 Subject: QML UI: don't crash when committing changes and unable to find the dive This mainly happens because add dive is completely broken right now, but in general it seems to be good policy not to blindly dereference this pointer... Signed-off-by: Dirk Hohndel --- qt-mobile/qmlmanager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index e684255c3..3a62fb342 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -279,6 +279,12 @@ void QMLManager::loadDivesWithValidCredentials() void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes) { struct dive *d = get_dive_by_uniq_id(diveId.toInt()); + qDebug() << diveId.toInt() << (d != 0 ? d->number : -1); + + if (!d) { + qDebug() << "don't touch this... no dive"; + return; + } bool diveChanged = false; if (!same_string(d->suit, suit.toUtf8().data())) { -- cgit v1.2.3-70-g09d2