gtk-rs / gtk4-rs

Rust bindings of GTK 4
https://gtk-rs.org/gtk4-rs/
MIT License
1.75k stars 168 forks source link

No method named `dispose_template` found for reference `&custom_buildable::imp::CustomBuildable` in the current scope #1754

Closed mtilda closed 1 month ago

mtilda commented 1 month ago

I am copying the Custom Buildable example in this repo using GTK 4.10.4 on Ubuntu 23.04.

You can see what crates I'm using in my Cargo.toml and Cargo.lock files.

gtk4 = "0.8.2"
imp = "0.1.0"

Problem

The program panics with the following error:

error[E0599]: no method named `dispose_template` found for reference `&custom_buildable::imp::CustomBuildable` in the current scope

Commenting out this line in my version of the code avoids the panic, but causes the following warning when I run the application and close the Custom Buildable window:

Gtk-WARNING **: 19:23:52.941: Finalizing CustomBuildable 0x55bcfa532b90, but it still has children left:
- GtkBox 0x55bcfa532ff0

Open questions

mtilda commented 1 month ago

When I clone this repo, cd into examples, and run cargo run --bin custom_buildable --features="v4_10", there is no error or warning. Surely I have configured something differently in my repo...

bilelmoussaoui commented 1 month ago

You forgot to enable the required feature for that function. As you can see in your command, you are enabling v4_10

mtilda commented 1 month ago

Okay, that makes sense. I am able to fix the error by modifying my Cargo.toml file like this:

 [dependencies]
-gtk4 = "0.8.2"
 imp = "0.1.0"
+
+[dependencies.gtk]
+package = "gtk4"
+version = "0.8.2"
+features = ["v4_10"]