Closed falbrechtskirchinger closed 1 year ago
Triggered by the "mutable" I feel this is the wrong approach:
WindowManager
already knows the currently shown tooltip (used for hiding it)
Great. I was unaware of this.
So how about adding a "UpdateTooltip" method to
WindowManager
that works similarly toWindowManager::SetToolTip
in checking if the currently shown tooltip is "THIS"? Or even better: Add an extra param toWindowManager::SetToolTip
:bool updateCurrent = false
to combine that into a single function. Maybe even useupdateCurrent = updateCurrent || tooltip.empty()
and do the check at
I think tooltip.empty()
should override updateCurrent
. Unless I'm missing something, the conditions don't mix cleanly the way you're describing. You'll see in a second.
https://github.com/Return-To-The-Roots/s25client/blob/bdf4110d761ddf73f235a8bdbd56fca8cf7cf941/libs/s25main/WindowManager.cpp#L839 only once (when
updateCurrent
(now) is set.)
I think
tooltip.empty()
should overrideupdateCurrent
. Unless I'm missing something, the conditions don't mix cleanly the way you're describing. You'll see in a second.
Can you elaborate? updateCurrent = updateCurrent || tooltip.empty()
accomplishes the override, doesn't it?
I'd have kept the ToolTip instance (in WindowManager) immutable and recreated it on change.
Anyway your solution works too 👍
I think
tooltip.empty()
should overrideupdateCurrent
. Unless I'm missing something, the conditions don't mix cleanly the way you're describing. You'll see in a second.Can you elaborate?
updateCurrent = updateCurrent || tooltip.empty()
accomplishes the override, doesn't it? I'd have kept the ToolTip instance (in WindowManager) immutable and recreated it on change.
Oh, right, because you would have just taken the branch re-creating the tooltip.
I'm not a fan of short-lived, frequent heap allocations, not because of the cost (which is often negligible), but because of heap fragmentation and resulting excessive memory consumption. glibc's malloc()
really sucks in that regard and applications can end up reserving obscene amounts of completely unused memory because it's full of unused holes.
Of course, the lines
vector is still bugging me for the same reason. :wink:
FYI, I have just confirmed that this does in fact work by testing these commits against #1604.
When a tooltip is currently being shown and its text is changed, update the displayed text.