Bug#1034878: #1034878 meld gives python traceback if run as root

2024-05-04 Thread Jeremy Bícha
Control: forwarded -1 https://gitlab.gnome.org/GNOME/meld/-/issues/846
Control: severity -1 minor

On Sat, May 4, 2024 at 8:42 AM  wrote:
> Bug #1034878 - meld gives python traceback if run as root is caused by the 
> call to Gtk.Settings.get_default() in settings.py at about line 56.

In general, GNOME developers and the Debian GNOME team don't want you
running apps as root/sudo. We do expect some things to be broken if
you try it anyway. However, you can try raising this issue directly
with the upstream meld developers who may be willing to apply a fix
for the issue. I notice that someone already reported a similar issue
today but maybe you can add a comment with your additional research.

https://gitlab.gnome.org/GNOME/meld/-/issues/846

Thank you,
Jeremy Bícha



Bug#1034878: #1034878 meld gives python traceback if run as root

2024-05-04 Thread jason
Bug #1034878   -
meld gives python traceback if run as root
  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)