Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit 25ef6ee

Browse files
committed
gtk: subclass: Ensure application subclasses log rt initialisation
When we subclass gtk::Application we won't be calling the manually defined Application::new() which means the runtime needs to be marked as initialised as part of the startup signal in the subclass. We simply shim that in during the translation of the signal from C into Rust land. Signed-off-by: Daniel Silverstone <[email protected]>
1 parent a29bdf8 commit 25ef6ee

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/subclass/application.rs

+15
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,26 @@ unsafe impl<T: ObjectSubclass + GtkApplicationImpl> IsSubclassable<T> for Applic
7575

7676
imp.window_removed(&wrap, &from_glib_borrow(wptr))
7777
}
78+
79+
unsafe extern "C" fn application_startup<T: ObjectSubclass>(ptr: *mut gio_sys::GApplication)
80+
where
81+
T: GtkApplicationImpl,
82+
{
83+
let instance = &*(ptr as *mut T::Instance);
84+
let imp = instance.get_impl();
85+
let wrap: Borrowed<gio::Application> = from_glib_borrow(ptr);
86+
crate::rt::set_initialized();
87+
imp.startup(&wrap)
88+
}
89+
7890
<gio::ApplicationClass as IsSubclassable<T>>::override_vfuncs(self);
7991
unsafe {
8092
let klass = &mut *(self as *mut Self as *mut gtk_sys::GtkApplicationClass);
8193
klass.window_added = Some(application_window_added::<T>);
8294
klass.window_removed = Some(application_window_removed::<T>);
95+
// Chain our startup handler in here
96+
let klass = &mut *(self as *mut Self as *mut gio_sys::GApplicationClass);
97+
klass.startup = Some(application_startup::<T>);
8398
}
8499
}
85100
}

0 commit comments

Comments
 (0)