[CALC] Fix input bug when display is in error. (#5988)
authorCarlo Bramini <carlo_bramini@users.sourceforge.net>
Thu, 18 Apr 2024 09:39:46 +0000 (11:39 +0200)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2024 09:39:46 +0000 (11:39 +0200)
CORE-19191

Reproduce the same behaviour of the calculator for Windows XP when an error condition is met.
When the result is NaN and it cannot be printed, the error condition is cleared by pressing the CLEAR button.

base/applications/calc/winmain.c

index 974216b..b2ab16c 100644 (file)
@@ -1635,7 +1635,7 @@ static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
         case IDC_BUTTON_D:
         case IDC_BUTTON_E:
         case IDC_BUTTON_F:
-            calc.is_nan = FALSE;
+            if (calc.is_nan) break;
             build_operand(hWnd, LOWORD(wp));
             return TRUE;
         case IDC_BUTTON_PERCENT:
@@ -1701,6 +1701,7 @@ static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
             }
             return TRUE;
         case IDC_BUTTON_BACK:
+            if (calc.is_nan) break;
             if (calc.sci_in) {
                 if (calc.esp == 0) {
                     TCHAR *ptr;