[wesnoth-commits] [wesnoth/wesnoth] 55f61f: lua/gui2: Restore layout invalidation hack when se...

Iris Morelle noreply at github.com
Sat May 15 10:15:57 UTC 2021


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 55f61fcdac24d6149a4841c13ee06aaabeed7551
      https://github.com/wesnoth/wesnoth/commit/55f61fcdac24d6149a4841c13ee06aaabeed7551
  Author: Iris Morelle <shadowm at wesnoth.org>
  Date:   2021-05-15 (Sat, 15 May 2021)

  Changed paths:
    M src/scripting/lua_widget_attributes.cpp

  Log Message:
  -----------
  lua/gui2: Restore layout invalidation hack when setting widget labels

Fixes #5755.

This is one of several layout invalidation hacks used in the old Lua
GUI2 API lost in the implementation of the new API (which the old API
now wraps).

It turns out that in the previous API (see 1.14 for reference if you
need easy access to the source) there were several calls to
invalidate_layout() that weren't there just to look pretty.

For wesnoth.set_dialog_value:

 * One prior to setting the value of a text_box
 * One prior to setting the value of a unit_preview_pane
 * One prior to setting the value of a styled_widget
 * One after changing a widget's visibility to hidden

All of these were removed by the new API implementation, with the last
one ending up commented out, restored now in commit
8989eb430311092e66177bc09e1b1c344000d5aa. All the other ones are
entirely gone, however.

It turns out that the dialog layout invalidation done for the
styled_widget case was essential to get listboxes working correctly
after clearing and adding rows to them (which was automatically done
right before in the implementation of wesnoth.set_dialog_value by the
find_widget() helper function). It was done for every single listbox
item, but without it the listbox would become completely useless under
certain conditions:

  20210501 03:24:37 error gui/layout: grid [_content_grid] place: Failed to place a grid, we have 39,30 space but we need 39,93 space. This happened at a grid with the id '_content_grid' in a 'N4gui27listboxE' with the id 'list' in a 'N4gui24gridE' with the id '_window_content_grid' in a 'N4gui24gridE' with the id '_content_grid' in a 'N4gui215scrollbar_panelE' with the id '' in a 'N4gui24gridE' with the id '' in a 'N4gui26windowE' with the id ''.

Now, it seems horribly inefficient to do this for every single new row
added to the listbox, but this solution *works*.

As for the text_box and unit_preview_pane cases, their presence or
absence doesn't seem to affect anything in my testing with a live
dialog, so I'm not adding them back until someone runs into a bug with
them.


  Commit: dd23418d7f5e94b17d03b9a4a24ea272b42be566
      https://github.com/wesnoth/wesnoth/commit/dd23418d7f5e94b17d03b9a4a24ea272b42be566
  Author: Iris Morelle <shadowm at wesnoth.org>
  Date:   2021-05-15 (Sat, 15 May 2021)

  Changed paths:
    M changelog.md

  Log Message:
  -----------
  Update changelog

[ci skip]


Compare: https://github.com/wesnoth/wesnoth/compare/8989eb430311...dd23418d7f5e



More information about the Commits mailing list