[PATCH] Don't crash if we try to save a empty plan

Lakshman acrlakshman at gmail.com
Sat Mar 22 13:55:30 PDT 2014


On Sat, Mar 22, 2014 at 9:13 AM, Anton Lundin <glance at acc.umu.se> wrote:
> Just treat it as a cancel instead.
>
> Signed-off-by: Anton Lundin <glance at acc.umu.se>
> ---
>  qt-ui/diveplanner.cpp | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
> index da5bb53..ac2662c 100644
> --- a/qt-ui/diveplanner.cpp
> +++ b/qt-ui/diveplanner.cpp
> @@ -1468,6 +1468,9 @@ void DivePlannerPointsModel::createPlan()
>         char *cache = NULL;
>         tempDive = NULL;
>
> +       if (!diveplan.dp)
> +               return cancelPlan();
> +
>         createTemporaryPlan();
>         plan(&diveplan, &cache, &tempDive, isPlanner());
>         copy_cylinders(stagingDive, tempDive);
> --
Instead of cancelling the plan, which sets the Mode to NOTHING, i.e.
user has to click on "New Plan" again, wouldn't it be better and
useful to add the following "if" statement, instead of the above one
     if (!rowCount()) return;
This way, Mode is not changed, and user can still be in PLAN mode,
i.e. same window.

Thank you,
Lakshman


More information about the subsurface mailing list