From ad126566929a102811c3219efc8521e2919eed8d Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Mon, 14 Oct 2024 16:57:25 -0400 Subject: [PATCH] prevent re-entry into UI state redraws, the redraw causes on-change events to call the redraw again should fix #24 --- BinxelviewForm.cs | 17 +++++++++++++++++ readme.txt | 2 ++ 2 files changed, 19 insertions(+) diff --git a/BinxelviewForm.cs b/BinxelviewForm.cs index b1cba2d..ea676cb 100644 --- a/BinxelviewForm.cs +++ b/BinxelviewForm.cs @@ -1514,8 +1514,12 @@ void redrawPixels() view_box.Image = pixel_bmp; } + private bool redrawPreset_active = false; void redrawPreset() { + if (redrawPreset_active) return; // prevent re-entry on UI value changes + redrawPreset_active = true; + if (preset.pixel_stride_auto) { preset.pixel_stride_byte = preset.bpp >> 3; @@ -1595,10 +1599,15 @@ void redrawPreset() } disable_pixel_redraw = old_disable_pixel_redraw; // restore pixel redraw + redrawPreset_active = false; } + private bool redrawPalette_active = false; void redrawPalette() { + if (redrawPalette_active) return; // prevent re-entry on UI value changes + redrawPalette_active = true; + autoPaletteSetup(); // disable these if BPP is too high to use an actual palette bool palenable = preset.bpp <= PALETTE_BITS; @@ -1620,10 +1629,16 @@ void redrawPalette() } paletteBox.Image = palette_bmp; paletteBox.Refresh(); + + redrawPalette_active = false; } + private bool redrawOptions_active = false; void redrawOptions() // make sure the UI state matches current options { + if (redrawOptions_active) return; // prevent re-entry on UI value changes + redrawOptions_active = true; + numericZoom.Value = zoom; gridOptionsMenuItem.Checked = !hidegrid; decimalPositionOptionsMenuItem.Checked = decimal_position; @@ -1663,6 +1678,8 @@ void redrawOptions() // make sure the UI state matches current options scrollRange(); } } + + redrawOptions_active = false; } public void splitviewClose() diff --git a/readme.txt b/readme.txt index 571feea..ddd78f4 100644 --- a/readme.txt +++ b/readme.txt @@ -279,6 +279,8 @@ Changes 1.6.3.0 (unreleased beta) - Fix relative INI path edge case, when the target directory has a similar name to the INI directory. +- Fix intermittent crash bug when changing presets (re-entrant code). +- Fix PixelView not updating scroll position on first open. 1.6.2.0 (2024-10-13) - Option persistence, INI file save and load.