From 714fdc7ced770c16126fadec2b0bf314e9b4a622 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 4 Jun 2014 13:41:50 -0700 Subject: Force TTS/NDL calculation off if things take too long This is kind of a random cut off, but if plotting the dive takes more than a second and TTS/NDL is on, we force it off. Because the algorithm for that is fundamentally quadratic in nature it can take a VERY long time - getting users to think something is broken. Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 67b0c4b9f..92c368cb8 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -355,6 +355,8 @@ void ProfileWidget2::setupSceneAndFlags() void ProfileWidget2::plotDives(QList dives) { static bool firstCall = true; + QTime measureDuration; // let's measure how long this takes us (maybe we'll turn of TTL calculation later + measureDuration.start(); // I Know that it's a list, but currently we are // using just the first. @@ -517,6 +519,12 @@ void ProfileWidget2::plotDives(QList dives) DivePlannerPointsModel *model = DivePlannerPointsModel::instance(); model->deleteTemporaryPlan(); } + // OK, how long did this take us? Anything above the second is way too long, + // so if we are calculation TTS / NDL then let's force that off. + if (measureDuration.elapsed() > 1000 && prefs.calcndltts) { + MainWindow::instance()->turnOffNdlTts(); + MainWindow::instance()->showError("Show NDL / TTS was disabled because of excessive processing time"); + } } void ProfileWidget2::settingsChanged() -- cgit v1.2.3-70-g09d2