Skip to content

How to properly use Gtk.Connect? #1122

Closed Answered by badcel
ravener asked this question in Q&A
Discussion options

You must be logged in to vote

It is currently a bit odd, I agree. As the fields are filled via reflection the flow analysis can't know about the initialization if you are using some *.ui files.

You could either not use *.ui files or initialize your member via [Gtk.Connect] private readonly Button button = default!; to have a none nullable field which gets initialized to value which is null, but not null for the compiler. As it is filed via reflection afterwards it should be fine as long as your *.ui file does not break.

The long term goal is to remove all the reflection code from the project which requires explicit initialization of the fields. This will probably happen via source generators to make life easier for th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@badcel
Comment options

Answer selected by ravener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants