After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 153854 - loses state when changing view
loses state when changing view
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Sami Pietilä
Sami Pietilä
: 306159 312416 314934 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-09-27 16:00 UTC by Stephen Kennedy
Modified: 2005-12-21 17:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix for this problem. (11.09 KB, text/plain)
2005-07-11 19:22 UTC, Rich Burridge
Details
Improvements for non-arithmetic operator precedence mode. (4.84 KB, text/plain)
2005-11-15 17:57 UTC, Rich Burridge
Details
Improvements for arithmetic operator precedence mode. (854 bytes, text/plain)
2005-11-28 20:55 UTC, Rich Burridge
Details
Fix for AOP code: "first thing userr does is change mode" scenerio. (518 bytes, text/plain)
2005-12-21 17:30 UTC, Rich Burridge
Details

Description Stephen Kennedy 2004-09-27 16:00:03 UTC
To reproduce:

Do a calculation
Change view (basic, ...)

Result:

Current calculation is lost. (changed to zero)

Expected

Calculation is not lost.
Comment 1 Rich Burridge 2004-09-27 16:13:44 UTC
This is not a bug. This is deliberate. Some of the 
functionality that is available in Scientific or
Financial mode simply isn't present in Basic mode,
therefore the display is reset.

Before I close this off as "not a bug", I've added
my HCI person to the cc: for his comments on this. 
Comment 2 Stephen Kennedy 2004-09-27 16:28:29 UTC
I should have been more clear. Changing Basic->Scientific still resets
even though it is a superset.

I think the interface should be:

if( representable in other view )
  switch view
else
  warn "changing views will lose your data"
  (with a never warn me again checkbox)
Comment 3 Calum Benson 2004-09-27 16:29:45 UTC
Well, the reporter does have a point... if the display is showing the *result*
of a calculation, there's probably not really any need to clear it when
switching modes unless any data loss would occur (e.g. if numbers are internally
held to less accuracy in Basic mode than Scientific mode, or something)-- in
which case you might just want to prompt for confirmation.  

Certainly you might also need to (for example) alert the user that you're
changing the display from Hex back to Decimal when switching from Scientific to
Basic mode, say (IMHO Basic mode should always be decimal-only), but you could
probably just do that in the status bar or something.

It's a different matter if you're part way through entering a calculation, and
switch to a mode where some of the functions you've entered don't exist in the
new mode.  Then clearing might be the only reasonable option, but you might
still want to ask for confirmation first to give the option of backing out.
Comment 4 Rich Burridge 2004-09-27 16:36:29 UTC
All good points (from Stephen and Calum). Will work out what needs 
to be done and adjust accordingly. Thanks!
Comment 5 Rich Burridge 2005-07-11 18:59:36 UTC
*** Bug 306159 has been marked as a duplicate of this bug. ***
Comment 6 Rich Burridge 2005-07-11 19:22:40 UTC
Created attachment 48978 [details]
Fix for this problem.
Comment 7 Rich Burridge 2005-07-11 19:35:53 UTC
Changes checked into CVS HEAD. Version number in configure.in
bumped to 5.6.21. I'll generate a new tarball in a few minutes.

Note that this warning dialog will always be displayed irrespective
of whether you are part way through a calculator or if the calculation
is complete. Although it's possible to determine if the calculation is
complete, with code that looks like:

    int complete = 1;     /* Set if the user has completed a calculation. */

    switch (v->syntax) {
        case npa:
            if (IS_KEY(v->old_cal_value, KEY_EQ.value[0])) {
                /* Calculation is complete. */
                complete = 0;
            }
            break;

        case exprs:
            if (v->e.calc_complete == 1) {
                /* Calculation is complete. */
                complete = 0;
            }
            break;
    }

there are too many other things (edge cases) that, if all accounted
for, make the code to handle this quite large. For example, going from
arithmetic operator precedence mode to non-arithmetic operator precedence
just before you change modes. It's just cleaner to always warn the user
and then clear the display (noting that the warning dialog can be prevented
from being displayed by checking the "don't show this to me again" box).

Note also that changing modes will:
* clear the display
* set the base to decimal
* set the numeric display to fixed
* set the accuracy to nine places after the numeric point.
* clear the display of the thousands separator
* clear the display of trailing zeroes after the numeric point.

and dismiss the register window if the new mode is Basic.

If all that was mentioned in the dialog, it would get quite wordy.
I'll make a note in the gcalctool documentation placeholder bug to
get this added to the online help.

In short, with the warning dialog now in place, the user should
hopefully train themselves to only change modes when they are at 
a practical point to do so.
Comment 8 Rich Burridge 2005-08-03 13:47:48 UTC
*** Bug 312416 has been marked as a duplicate of this bug. ***
Comment 9 Rich Burridge 2005-08-31 14:11:26 UTC
*** Bug 314934 has been marked as a duplicate of this bug. ***
Comment 10 Martin Ejdestig 2005-11-14 21:35:29 UTC
Most users will probably think something like "let me get back to work" and just
click the check box, close it... and when they change mode sometime in the
future... oups, calculations lost.

Isn't there an easy fix that gets this "right" without showing a dialog most of
the time? I.e. if a numerical value is shown in the display, do all or almost
all, I don't know, of the stuff you do now but don't get rid of the value?
Comment 11 Rich Burridge 2005-11-14 22:15:07 UTC
> I don't know, of the stuff you do now ...

Comment #7 above pretty much summarises all the things that
need to be handled. 
Comment 12 Martin Ejdestig 2005-11-14 23:00:36 UTC
So why not just do it and always warn the user and reset in all other edge cases
(that would intriduce a large chunk of code that would make it hard to handle)?

Wasn't that basically what Calum said in comment 3?
Comment 13 Martin Ejdestig 2005-11-14 23:09:48 UTC
Hum, sorry, maybe it wasn't... you talk about cases that are hard to detect...

But if the by far most common case is easy to detect then why not just do the
conversion and skip the dialog in that case?
Comment 14 Rich Burridge 2005-11-15 03:16:06 UTC
A valid point. Okay, I'll reopen it and see if I can indeed do that.
Comment 15 Rich Burridge 2005-11-15 17:57:19 UTC
Created attachment 54790 [details]
Improvements for non-arithmetic operator precedence mode.
Comment 16 Rich Burridge 2005-11-15 18:05:17 UTC
If the user has completed a calculation and we are going to a
new mode that is "compatible" with this one, then just change
modes. Otherwise display a dialog warning the user that the
current calculation will be cleared.

Incompatible modes are:

Scientific -> Basic
Scientific -> Advanced
Scientific -> Financial

(unless we are in Scientific mode with Decimal numeric base and Fixed).

These changes work nicely in non-arithmetic operator precedence mode.
They've been checked into CVS HEAD and the version number in configure.in
has been bumped to 5.7.12.

For some reason, the display is still being cleared in arithmetic
operator precedence mode, even though it's going through the right
code path earlier. 

Keeping the bug open and transferring to Sami for further evaluation.
Comment 17 Rich Burridge 2005-11-28 20:55:12 UTC
Created attachment 55337 [details]
Improvements for arithmetic operator precedence mode.

Similar change to that made on 15th November 2005, this time for
arithmetic operator precedence (AOP) mode. 

Changes checked into CVS HEAD. Version number in configure.in 
bumped to v5.7.14.

Still need to correctly handle this is AOP mode if it's the first 
thing the user does, so I'll keep the bug open for this.
Comment 18 Rich Burridge 2005-12-21 17:30:38 UTC
Created attachment 56261 [details]
Fix for AOP code: "first thing userr does is change mode" scenerio.

Diff from Sami for the last piece of this fix.
Comment 19 Rich Burridge 2005-12-21 17:31:48 UTC
Changes checked into CVS HEAD. Version number bumped to 5.7.18.
Fix should turn up in the gcalctool tarball for GNOME 2.13.4.