mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
f34e6218a0
commit
714fdc7ced
3 changed files with 15 additions and 0 deletions
|
@ -1226,6 +1226,12 @@ void MainWindow::on_profNdl_tts_clicked(bool triggered)
|
|||
prefs.calcndltts = triggered;
|
||||
TOOLBOX_PREF_PROFILE(calcndltts);
|
||||
}
|
||||
void MainWindow::turnOffNdlTts()
|
||||
{
|
||||
const bool triggered = prefs.calcndltts = false;
|
||||
TOOLBOX_PREF_PROFILE(calcndltts);
|
||||
}
|
||||
|
||||
void MainWindow::on_profPhe_clicked(bool triggered)
|
||||
{
|
||||
prefs.pp_graphs.phe = triggered;
|
||||
|
|
|
@ -148,6 +148,7 @@ protected:
|
|||
|
||||
public
|
||||
slots:
|
||||
void turnOffNdlTts();
|
||||
void readSettings();
|
||||
void refreshDisplay(bool doRecreateDiveList = true);
|
||||
void recreateDiveList();
|
||||
|
|
|
@ -355,6 +355,8 @@ void ProfileWidget2::setupSceneAndFlags()
|
|||
void ProfileWidget2::plotDives(QList<dive *> 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<dive *> 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()
|
||||
|
|
Loading…
Add table
Reference in a new issue