Skip to content

Commit

Permalink
Catch error for non-standard cursor
Browse files Browse the repository at this point in the history
Adwaita icon theme does not contain `exchange` legacy X11 cursor
so attempting to mask HCY wheel on GNOME will cause a crash:

    Gdk-Message: Unable to load exchange from the cursor theme
    TypeError: constructor returned NULL

Let’s catch the error like in cf14342
and fall back to default cursor when not present.
  • Loading branch information
jtojnar committed Feb 3, 2024
1 parent d7d2496 commit 5496b1c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gui/colors/hcywheel.py
Expand Up @@ -431,13 +431,20 @@ def __init__(self):
def _realize_cb(self, widget):
display = self.get_window().get_display()

# non-standard cursor
self.__add_cursor = Gdk.Cursor.new_from_name(display, "plus")
try:
# non-standard cursor
self.__add_cursor = Gdk.Cursor.new_from_name(display, "plus")
except Exception:
self.__add_cursor = Gdk.Cursor.new_from_name(display, "default")
self.__move_cursor = Gdk.Cursor.new_from_name(display, "move")
self.__move_point_cursor = Gdk.Cursor.new_from_name(
display, "crosshair")
# non-standard cursor
self.__rotate_cursor = Gdk.Cursor.new_from_name(display, "exchange")
try:
# non-standard cursor
self.__rotate_cursor = Gdk.Cursor.new_from_name(
display, "exchange")
except Exception:
self.__rotate_cursor = Gdk.Cursor.new_from_name(display, "grab")

def __leave_cb(self, widget, event):
# Reset the active objects when the pointer leaves.
Expand Down

0 comments on commit 5496b1c

Please sign in to comment.