gtk-rs / glib

DEPRECATED, use https://github.com/gtk-rs/gtk-rs-core repository instead!
http://gtk-rs.org/
MIT License
93 stars 62 forks source link

Fix double registration of GEnums #721

Closed TobiasMorell closed 4 years ago

TobiasMorell commented 4 years ago

The GEnum derive macro did not check whether an enum exists before registering it, leading to a panic if the same enum is registered twice:

GLib-GObject-WARNING **: 08:04:50.392: cannot register existing type 'EnumName'
thread '<unnamed>' panicked at 'assertion failed: `(left != right)`
  left: `<invalid>`,
  right: `<invalid>`', /path/to/source.rs
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This PR makes sure that enums are only registered if gobject_sys::g_type_from_name returns 0.