Hi, as promised earlier, this patch removes the global state variable and replaces it with a helper function to determine the state of the main window.
Best Robert
From 351cdc0229013d88814ee66d0101d744f05fd204 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Tue, 18 Aug 2015 10:03:51 +0200 Subject: [PATCH] Replace global in_planner variable by helper function as promised earlier Signed-off-by: Robert C. Helling <[email protected]> --- planner.c | 8 -------- qt-ui/mainwindow.cpp | 6 +++++- qt-ui/mainwindow.h | 1 + qthelper.cpp | 6 ++++++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/planner.c b/planner.c index 001f651..0d073bd 100644 --- a/planner.c +++ b/planner.c @@ -33,14 +33,6 @@ int decostoplevels_imperial[] = { 0, 3048, 6096, 9144, 12192, 15240, 18288, 2133 double plangflow, plangfhigh; bool plan_verbatim, plan_display_runtime, plan_display_duration, plan_display_transitions; -/* This is a bit round about: Currently, we only support VPM-B in the planner, - * so, when we compute ceilings we have to know if we are in planning mode since - * the maximally allowed gradient in the tissues is determined by the critical volume algorithm for - * which we currently have no version for logged dives. But the information about the application state - * is only available in the C++/Qt part. So this global variable is a way to leak this info. */ - -bool in_planner = false; - const char *disclaimer; #if DEBUG_PLAN diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index f22884a..1a12305 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -1716,7 +1716,6 @@ void MainWindow::setApplicationState(const QByteArray& state) { return; currentApplicationState = state; - in_planner = (state == "PlanDive" || state == "EditPlannedDive"); #define SET_CURRENT_INDEX( X ) \ if (applicationState[state].X) { \ @@ -1732,3 +1731,8 @@ void MainWindow::setApplicationState(const QByteArray& state) { SET_CURRENT_INDEX( bottomRight ) #undef SET_CURRENT_INDEX } + +bool MainWindow::inPlanner() +{ + return (currentApplicationState == "PlanDive" || currentApplicationState == "EditPlannedDive"); +} diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 583dc59..4df1d12 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -89,6 +89,7 @@ public: void printPlan(); void checkSurvey(QSettings *s); void setApplicationState(const QByteArray& state); + bool inPlanner(); QUndoStack *undoStack; NotificationWidget *getNotificationWidget(); void enableDisableCloudActions(); diff --git a/qthelper.cpp b/qthelper.cpp index 14a48c1..44bb8a3 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -12,6 +12,7 @@ #include <exif.h> #include "file.h" #include "prefs-macros.h" +#include "mainwindow.h" #include <QFile> #include <QRegExp> #include <QDir> @@ -1272,3 +1273,8 @@ extern "C" void parse_display_units(char *line) { qDebug() << line; } + +extern "C" bool in_planner() +{ + return MainWindow::instance()->inPlanner(); +} -- 1.9.5 (Apple Git-50.3)
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
