Fox object lifetime management

This commit is contained in:
Kovid Goyal 2022-12-30 10:08:49 +05:30
parent 4f9ed6546a
commit 080d1bf935
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -630,17 +630,16 @@ draw_hyperlink_target(OSWindow *os_window, Screen *screen, const CellRenderData
Py_CLEAR(bd->last_drawn_title_object_id); Py_CLEAR(bd->last_drawn_title_object_id);
const char *url = get_hyperlink_for_id(screen->hyperlink_pool, bd->hyperlink_id_for_title_object, true); const char *url = get_hyperlink_for_id(screen->hyperlink_pool, bd->hyperlink_id_for_title_object, true);
if (url == NULL) url = ""; if (url == NULL) url = "";
PyObject *h = PyObject_CallMethod(global_state.boss, "sanitize_url_for_dispay_to_user", "s", url); bd->last_drawn_title_object_id = PyObject_CallMethod(global_state.boss, "sanitize_url_for_dispay_to_user", "s", url);
if (h == NULL) { PyErr_Print(); return; } if (bd->last_drawn_title_object_id == NULL) { PyErr_Print(); return; }
bd->last_drawn_title_object_id = h;
Py_INCREF(bd->last_drawn_title_object_id);
bd->needs_render = true; bd->needs_render = true;
} }
if (bd->last_drawn_title_object_id == NULL) return; if (bd->last_drawn_title_object_id == NULL) return;
const bool along_bottom = screen->lines < 3 || screen->current_hyperlink_under_mouse.y < screen->lines - 2; const bool along_bottom = screen->lines < 3 || screen->current_hyperlink_under_mouse.y < screen->lines - 2;
Py_INCREF(bd->last_drawn_title_object_id); PyObject *ref = bd->last_drawn_title_object_id;
Py_INCREF(ref);
render_a_bar(os_window, screen, crd, &window->title_bar_data, bd->last_drawn_title_object_id, along_bottom); render_a_bar(os_window, screen, crd, &window->title_bar_data, bd->last_drawn_title_object_id, along_bottom);
Py_DECREF(bd->last_drawn_title_object_id); Py_DECREF(ref);
} }
static void static void