Gnome: register custom GTypes before templates - #110
Merged
Conversation
Blueprint templates reference custom widgets by GTypeName (e.g.
$TutorialView, $QuickHelpView, $SourceView). Those types must be
registered before a template embedding them is instantiated, or GTK
aborts with "Invalid object type '<Name>'".
Each widget self-registers on module load, but several consumers
imported their children with `import type { ... }`, which the bundler
strips entirely — so the modules were never evaluated/registered. This
surfaced after the dependency/formatter bump in #103.
Add src/register-types.ts, a side-effect import barrel for every
self-registering widget/view module, loaded early from main.ts so all
GTypes exist before the first window template is built.
Fixes #106
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.
Problem
After #103 (dependency + oxc formatter bump), running
yarn && yarn build && yarn startaborts while building the main window with:No usable window opens. Fixes #106.
Root cause
Blueprint templates reference custom widgets by their
GTypeName(e.g.$TutorialView,$QuickHelpView,$SourceView). A custom type must be registered with the GObject type system before any template embedding it is instantiated.Each widget module self-registers via its static
GObject.registerClass(...)block (plus a trailingGObject.type_ensure(...)), but that code only runs if the module is actually evaluated. Several consumers import their child widgets withimport type { ... }(e.g.main.window.tsimportsLearn/Editor/GameConsole/Debuggeras types). The bundler strips type-only imports entirely, so those modules were never pulled into the bundle and never registered. The dependency/formatter bump in #103 changed the bundling so the latent bug started biting.The rebuilt binary grew from ~531 KB to ~731 KB, confirming the widget modules were previously being tree-shaken out.
Fix
Add
src/register-types.ts, a side-effect import barrel for every self-registering widget/view/dialog module, loaded early frommain.ts(beforeApplicationis constructed). This guarantees all GTypes exist before the first window template is built.Verification
yarn check:typescript(gjsify tsc) passes.yarn check:formatpasses.LC_ALL=he_IL.UTF-8 LANGUAGE=he): noInvalid object type, noreturned NULL, no related JS errors; all views (learn/editor/debugger/game console) build and the simulator runs.