GNOME Bugzilla – Bug 705640
GtkWindow incorrectly requires a default screen
Last modified: 2017-08-31 19:32:31 UTC
gtk_window_init now depends on a default screen. This was introduced with the code: #ifdef GDK_WINDOWING_X11 g_signal_connect (gtk_settings_get_for_screen (priv->screen), "notify::gtk-application-prefer-dark-theme", G_CALLBACK (gtk_window_on_theme_variant_changed), window); #endif Note, that the code immediately before specifically checks for priv->screen being non-NULL before attaching a signal. There also seems to be some mismatch between this code and code in gtk_window_finalize. The signal is connected to one object and appears to be be disconnected from a different object. At the very least it looks weird.
(In reply to Morten Welinder from comment #0) > Note, that the code immediately before specifically checks for priv->screen > being non-NULL before attaching a signal. Yeah, that X11-specific connection really should be made in that above if(priv->screen) block too. Every other related bit that's X11-specific does this. It's not clear why this is only done in X11, but I don't know the background. > There also seems to be some mismatch between this code and code in > gtk_window_finalize. The signal is connected to one object and appears > to be be disconnected from a different object. At the very least it looks > weird. It looks OK to me.
Yeah, no, it is weird: init() uses g_signal_connect, while set_screen() uses g_signal_connect_object, which is strangely inconsistent. Presumably we can make both sites use connect_object(), then remove the manually disconnect_by_func()s from finalize(). Or the converse: use connect() for both.
Created attachment 358885 [details] [review] Window: Connect screen signals properly in init() Do not connect to get_settings_for_screen() if we have no screen… Use g_signal_connect(), not connect_object(), to match how set_screen() makes these same connections, and how finalize() already disconnects.