"TypeError: constructor returned NULL" in WSL
I ran into an issue with meld on Windows WSL2. The error displayed on the console is:
2022-10-19 14:03:25,596 INFO Gtk: Gdk-Message: 14:03:25.596: Unable to load sb_h_double_arrow from the cursor theme
Traceback (most recent call last):
File "/home/dornbier/meld/meld/diffgrid.py", line 35, in do_realize
self._handle1.realize(self)
File "/home/dornbier/meld/meld/diffgrid.py", line 281, in realize
attr.cursor = Gdk.Cursor.new_for_display(widget.get_display(),
TypeError: constructor returned NULL
Building off of this fix https://github.com/matplotlib/matplotlib/issues/19405#issuecomment-770244923, I was able to resolve it with the following patch:
diff --git a/meld/diffgrid.py b/meld/diffgrid.py
index c03e4ab7..05fab041 100644
--- a/meld/diffgrid.py
+++ b/meld/diffgrid.py
@@ -278,9 +278,8 @@ class HandleWindow():
Gdk.EventMask.ENTER_NOTIFY_MASK |
Gdk.EventMask.LEAVE_NOTIFY_MASK |
Gdk.EventMask.POINTER_MOTION_MASK)
- attr.cursor = Gdk.Cursor.new_for_display(widget.get_display(),
- Gdk.CursorType.
- SB_H_DOUBLE_ARROW)
+ attr.cursor = Gdk.Cursor.new_from_name(widget.get_display(),
+ "ew-resize")
attr_mask = (Gdk.WindowAttributesType.X |
Gdk.WindowAttributesType.Y |
Gdk.WindowAttributesType.CURSOR)
It would be great if someone could check this and potentially get it into the repo. According to https://docs.gtk.org/gdk3/class.Cursor.html, new_from_name
is only available since 2.8, not sure if that is an issue.