Skip to content

Commit

Permalink
Properly revert cursor when using set_custom_mouse_cursor with null
Browse files Browse the repository at this point in the history
Fixes #32486
  • Loading branch information
pouleyKetchoupp committed Oct 3, 2019
1 parent 09bf1b3 commit 5bfe32e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions platform/javascript/os_javascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
}, cursors[p_shape].utf8().get_data());
/* clang-format on */
cursors[p_shape] = "";

cursors_cache.erase(p_shape);
}

set_cursor_shape(cursor_shape);
Expand Down
7 changes: 6 additions & 1 deletion platform/osx/os_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1973,11 +1973,16 @@ virtual void log_error(const char *p_function, const char *p_file, int p_line, c
[nsimage release];
} else {
// Reset to default system cursor
cursors[p_shape] = NULL;
if (cursors[p_shape] != NULL) {
[cursors[p_shape] release];
cursors[p_shape] = NULL;
}

CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX;
set_cursor_shape(c);

cursors_cache.erase(p_shape);
}
}

Expand Down
7 changes: 6 additions & 1 deletion platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,11 +2485,16 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
DeleteObject(bitmap);
} else {
// Reset to default system cursor
cursors[p_shape] = NULL;
if (cursors[p_shape]) {
DestroyIcon(cursors[p_shape]);
cursors[p_shape] = NULL;
}

CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX;
set_cursor_shape(c);

cursors_cache.erase(p_shape);
}
}

Expand Down
2 changes: 2 additions & 0 deletions platform/x11/os_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,8 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
CursorShape c = current_cursor;
current_cursor = CURSOR_MAX;
set_cursor_shape(c);

cursors_cache.erase(p_shape);
}
}

Expand Down

0 comments on commit 5bfe32e

Please sign in to comment.