Skip to content

Commit

Permalink
prevent re-entry into UI state redraws, the redraw causes on-change e…
Browse files Browse the repository at this point in the history
…vents to call the redraw again

should fix #24
  • Loading branch information
bbbradsmith committed Oct 14, 2024
1 parent 175271c commit ad12656
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions BinxelviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1663,6 +1678,8 @@ void redrawOptions() // make sure the UI state matches current options
scrollRange();
}
}

redrawOptions_active = false;
}

public void splitviewClose()
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ad12656

Please sign in to comment.