Emit buttons - Button existed but nothing ever constructed it - #60
Open
TheLastDarkthorne wants to merge 1 commit into
Open
Emit buttons - Button existed but nothing ever constructed it#60TheLastDarkthorne wants to merge 1 commit into
TheLastDarkthorne wants to merge 1 commit into
Conversation
muddler shipped a Button class that no code path reached. App.groovy builds five packages (alias, script, timer, trigger, key) and yields those five into the MudletPackage, and there was no ButtonPackage or ActionPackage to build. A project with a populated src/buttons/ built without complaint and without buttons: "Scanning for buttons" never appeared in the log and the output XML had no ActionPackage at all. Adds ActionPackage, following the same shape as the other five - scans build/filtered/src/buttons for buttons.json, and constructs Buttons. Button itself only looked finished. It declared the fields but the constructor set none of them, so every one would have serialised as null even once something did construct it. It now maps its options and writes Mudlet's Action/ActionGroup element: the isPushButton, isFlatButton and useCustomLayout attributes, and the sixteen child elements Mudlet expects, each defaulting to what a freshly created button carries rather than to empty. The layout numbers are bare integers Mudlet is unforgiving about, so they default rather than being omitted. orientation is the one that differs between a toolbar and a button on it, and follows isFolder. buttonColor is written only when set. Packages from the Mudlet 3.x era have no such element and emitting an empty one on every button would change every imported package to no purpose. Verified by building a project whose src/buttons/ holds a toolbar with one button and a sibling trigger as a canary: before, the trigger came through and the button left no trace anywhere in the output; after, ActionPackage carries the ActionGroup with the nested Action, and the button's script is read from its .lua the same way every other item type reads one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Button.groovyexists and nothing constructs it.App.groovybuilds fivepackages - alias, script, timer, trigger, key - and yields those five into
the
MudletPackageXML. There is no sixth for buttons. A project with apopulated
src/buttons/builds without complaint and without buttons:"Scanning for buttons" never appears in the log, the way it does for every
other item type, and the output XML has no
Action/ActionGroupelement atall.
Fixes #58.
Repro: a minimal project with
src/buttons/buttons.jsondeclaring a toolbarwith one button and its
Show_affs.lua, plus a siblingsrc/triggers/trigger as a canary. Before this fix, the trigger comes through and the
button leaves no trace anywhere in the output. This is also why a converted
package's toolbar can vanish silently on the muddler round-trip with nothing
in the converter itself at fault - there is no code path that could keep it.
The fix
Adds
ActionPackage, following the same shape as the other five: it scansbuild/filtered/src/buttonsforbuttons.jsonand constructsButtons.Buttonitself only looked finished - it declared its fields but theconstructor set none of them, so every button would have serialised as null
even once something did construct it. It now maps its options and writes
Mudlet's
Action/ActionGroupelement: theisPushButton,isFlatButtonand
useCustomLayoutattributes, and the sixteen child elements Mudletexpects, each defaulting to what a freshly created button carries rather
than to empty. The layout numbers are bare integers Mudlet is unforgiving
about, so they default instead of being omitted;
orientationis the onethat differs between a toolbar and a button on it, and follows
isFolder.buttonColoris written only when set - packages from the Mudlet 3.x erahave no such element, and emitting an empty one on every button would change
every imported package to no purpose.
Verification
Built the repro above before and after: before, the trigger appears and the
button leaves no trace; after,
ActionPackagecarries theActionGroupwiththe nested
Action, and the button's script is read from its.luathe sameway every other item type reads one.
Runnable reproduction
https://github.com/TheLastDarkthorne/mudlet-tooling-repros/tree/main/muddler/bug6-missing-buttons
Run against the stock 1.1.0 jar, the canary trigger builds and the button
leaves no trace anywhere in the output.
run_repros.pyin the samedirectory builds it against both a stock and a patched jar and prints the
resulting tree for both.