Commit 624ea3ec authored by Christoph Reiter's avatar Christoph Reiter 🐍

gtk: raise in case Gtk.Window is instantiated after init failed. See #298

gtk crashes if gtk_init() fails and we can't do much about it.
This assumes the Gtk.Window() is the first instantiated widget and
raises an exception in case init failed.

We already had such a check but it was removed in 86a37d67
for some reason (maybe because it only helps in some cases)
parent 208a6295
......@@ -506,11 +506,19 @@ __all__.append('Builder')
# NOTE: This must come before any other Window/Dialog subclassing, to ensure
# that we have a correct inheritance hierarchy.
_window_init = deprecated_init(Gtk.Window.__init__,
arg_names=('type',),
category=PyGTKDeprecationWarning,
stacklevel=3)
class Window(Gtk.Window):
__init__ = deprecated_init(Gtk.Window.__init__,
arg_names=('type',),
category=PyGTKDeprecationWarning)
def __init__(self, *args, **kwargs):
if not initialized:
raise RuntimeError(
"Gtk couldn't be initialized. "
"Use Gtk.init_check() if you want to handle this case.")
_window_init(self, *args, **kwargs)
Window = override(Window)
......@@ -1627,7 +1635,7 @@ if Gtk._version in ("2.0", "3.0"):
__all__.append('stock_lookup')
if Gtk._version == "4.0":
Gtk.init_check()
initialized = Gtk.init_check()
else:
initialized, argv = Gtk.init_check(sys.argv)
sys.argv = list(argv)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment