Bug #1034878 <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1034878>  -
meld gives python traceback if run as root
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1034878>  is caused by
the call to Gtk.Settings.get_default() in settings.py at about line 56.

 

This code still exists in the head of the git repo.



As per the PyAPI manual at
https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Settings.html#Gtk.Settings.
get_default . If Gtk is not initialised (which often happens when you sudo
root over a remote shell as you need to pass xauth) then the call to
Gtk.Settings.get_default() will fail and return None.  This is not handled.
The issue is that a couple lines down instead of referencing
Gtk.Setting.props it now looks for (None).props... and breaks as per the bug
report.  Something like following two/four lines are required, though that
is really only a partial fix, as this will eliminate the Python error as per
the bug, but meld will still die horribly this time with a Gtk error, rather
than exit gracefully while informing the user.
I don't know enough about Gtk or meld to fix that.

 


            gtk_settings = Gtk.Settings.get_default()

>          # get_default() returns None if there is no graphics, 

 >          # even if the user has settings in their profile

>          if gtk_settings is None:

>             return

             prefer_dark = settings.get_boolean(key)

             gtk_settings.props.gtk_application_prefer_dark_theme =
prefer_dark

Cheers,

Jay (the-moog at github)

Reply via email to