Skip to content

fix: data grid header keeps showing previous table's columns on macOS#2549

Open
twinn1013 wants to merge 1 commit into
HeidiSQL:lazarusfrom
twinn1013:fix-datagrid-stale-header-macos
Open

fix: data grid header keeps showing previous table's columns on macOS#2549
twinn1013 wants to merge 1 commit into
HeidiSQL:lazarusfrom
twinn1013:fix-datagrid-stale-header-macos

Conversation

@twinn1013

Copy link
Copy Markdown
Collaborator

Fixes #2548

On macOS, loading the data grid happens inside a paint cycle (OnBeforePaint), and Cocoa discards invalidations issued while a paint cycle is running. The header is painted before OnBeforePaint fires, so after switching tables it kept showing the previous table's columns until some unrelated event repainted the window (scroll, resize or focus change). Full root cause analysis with lldb backtraces is in the issue.

This change queues one asynchronous repaint (Application.QueueAsyncCall) at the end of DataGridBeforePaint, which runs right after the current paint cycle finishes, so the new header becomes visible immediately. No query re-execution, and everything is inside {$IFDEF DARWIN}, so Windows and Linux builds are byte-identical.

Tested on an M5 Mac: headers now update instantly on every table switch, and sort arrows / column numbering are correct as well.

Loading the data grid happens inside a paint cycle (OnBeforePaint), and
Cocoa discards invalidations issued while a paint cycle is running. The
header is painted before OnBeforePaint fires, so after switching tables
it kept showing the previous table's columns until some unrelated event
repainted the window. Queue an asynchronous repaint which runs right
after the current paint cycle, so the new header becomes visible
immediately. Darwin-only change.
@twinn1013 twinn1013 self-assigned this Jul 14, 2026
@twinn1013 twinn1013 added bug Defective behaviour in HeidiSQL macos Affects the macOS app bundle labels Jul 14, 2026
@ansgarbecker

Copy link
Copy Markdown
Collaborator

Thanks for your suggested change. I think using QueueAsyncCall is the right direction - there is no other fitting event which already has code, and we cannot use the OnAfterPaint event without ending in a paint loo. The RemoveAsyncCalls also looks reasonable - that prevents us from crashes at the end of a session. Only I would like to discard the IFDEF DARWIN's, I think the additional code comes at nearly zero cost on Linux and Windows. And the invalidation itself can be done on the header instead of the whole tree:

TLazVirtualStringTree(Data).Header.Invalidate(nil, True);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Defective behaviour in HeidiSQL macos Affects the macOS app bundle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants