Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFW-6958] GUI: Fix footer update after selecting None #4345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bkerler
Copy link

@bkerler bkerler commented Dec 14, 2024

This fixes issue #4166.

After selecting None in the Footer settings menu, the existing footer item isn't erased, thus stays active although it has been disabled.

@@ -51,6 +51,8 @@ bool FooterLine::Create(footer::Item item_id, size_t index) {

if (result) {
positionWindows();
} else if (item_id == footer::Item::none) {
Erase(index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be a correct fix. The result is set to true on any change, which should call positionWindows. That is, even on change to/from none. This thing might possibly work, but it's a bit random, plus it will call positionWindows each time (inside Erase), suboptimally.

By quickly looking at the code, the proper/elegant fix would probably be to add FooterItemMappingRec<std::monostate, Item::none> to FooterItemMappings

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to add FooterItemMappingRec as suggested doesn't work due to compiler error:
error: static assertion failed: T must occur exactly once in alternatives [build] 1115 | static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,.
As far as I could see, Erase doesn't call positionWindows and it only is erased if result is false, which happens if the item isn't registered (which is only the case for footer::item::none).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm now using unregister directly and also moved it above the FooterItemsMapping function, which should be a more proper way to do it. If you have any ideas how to make the FooterItemMappingRec working with std::monostate, please let me know :)

@bkerler bkerler force-pushed the Fix_footer_update branch 2 times, most recently from 4202f5a to acade0a Compare December 14, 2024 17:20
@@ -41,6 +41,9 @@ bool FooterLine::Create(footer::Item item_id, size_t index) {

if (item_id >= footer::Item::_count) {
item_id = footer::Item::none;
} else if (item_id == footer::Item::none) {
unregister(index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not call positionWindows, which it probably should in some cases (at least according to the previous code).

@@ -41,6 +41,9 @@ bool FooterLine::Create(footer::Item item_id, size_t index) {

if (item_id >= footer::Item::_count) {
item_id = footer::Item::none;
} else if (item_id == footer::Item::none) {
unregister(index);
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is rather debatable whether this should call true or false. From the previous code, it rather seems like the function should return true if an item is changed (and in that case, and only in that case, it should call reposition). This code does not follow that logic.

But looking around, it seems like the return value is not used anywhere, so it would perhaps be best to just turn it into a procedure.

@bkerler bkerler marked this pull request as draft December 18, 2024 13:45
@bkerler bkerler force-pushed the Fix_footer_update branch 4 times, most recently from affb6c1 to 10004c0 Compare March 18, 2025 19:59
@bkerler bkerler marked this pull request as ready for review March 18, 2025 20:01
@bkerler bkerler force-pushed the Fix_footer_update branch 4 times, most recently from 064c779 to f0aa2e1 Compare March 21, 2025 16:40
@bkerler bkerler force-pushed the Fix_footer_update branch from f0aa2e1 to a99cd60 Compare March 21, 2025 16:42
@bkerler bkerler requested a review from CZDanol March 21, 2025 16:44
@CZDanol CZDanol changed the title GUI: Fix footer update after selecting None [BFW-6958] GUI: Fix footer update after selecting None Mar 21, 2025
@CZDanol
Copy link
Contributor

CZDanol commented Mar 21, 2025

Internal ticket: BFW-6958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants