Handle on_drop being called with a POSIX errno
This commit is contained in:
parent
ff70e2e3ab
commit
abb1141826
2 changed files with 9 additions and 5 deletions
|
|
@ -1885,9 +1885,14 @@ def update_tab_bar_data(self, os_window_id: int) -> None:
|
|||
if tm is not None:
|
||||
tm.update_tab_bar_data()
|
||||
|
||||
def on_drop(self, os_window_id: int, drop: dict[str, bytes] | Exception, from_self: bool, x: int, y: int) -> None:
|
||||
if isinstance(drop, Exception):
|
||||
self.show_error(_('Drop failed'), str(drop))
|
||||
def on_drop(self, os_window_id: int, drop: dict[str, bytes] | int, from_self: bool, x: int, y: int) -> None:
|
||||
if isinstance(drop, int):
|
||||
import errno
|
||||
code = errno.errorcode.get(drop, str(drop))
|
||||
msg = 'Unknown error'
|
||||
with suppress(ValueError):
|
||||
msg = os.strerror(drop)
|
||||
self.show_error(_('Drop failed'), f'[{code}] {msg}')
|
||||
return
|
||||
if (tm := self.os_window_map.get(os_window_id)) is None:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1669,8 +1669,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
|
|||
glfwSetScrollCallback(glfw_window, scroll_callback);
|
||||
glfwSetKeyboardCallback(glfw_window, key_callback);
|
||||
|
||||
if (0) glfwSetDragSourceCallback(glfw_window, drag_source_callback);
|
||||
|
||||
glfwSetDragSourceCallback(glfw_window, drag_source_callback);
|
||||
glfwSetDropEventCallback(glfw_window, on_drop);
|
||||
monotonic_t now = monotonic();
|
||||
w->is_focused = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue