Simplify XDND toplevel freeing code
* src/xterm.c (x_free_dnd_toplevels): New function. (x_dnd_cleanup_drag_and_drop, x_dnd_begin_drag_and_drop): Record an unwind function to free DND toplevels instead of doing that manually everywhere.
This commit is contained in:
parent
496e191fc7
commit
b8e0f2e827
1 changed files with 14 additions and 14 deletions
28
src/xterm.c
28
src/xterm.c
|
@ -4163,6 +4163,18 @@ x_free_dnd_targets (void)
|
|||
x_dnd_n_targets = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x_free_dnd_toplevels (void)
|
||||
{
|
||||
if (!x_dnd_use_toplevels || !x_dnd_toplevels)
|
||||
return;
|
||||
|
||||
/* If the display is deleted, x_dnd_toplevels will already be
|
||||
NULL, so we can always assume the display is alive here. */
|
||||
|
||||
x_dnd_free_toplevels (true);
|
||||
}
|
||||
|
||||
static void
|
||||
x_dnd_cleanup_drag_and_drop (void *frame)
|
||||
{
|
||||
|
@ -4216,9 +4228,6 @@ x_dnd_cleanup_drag_and_drop (void *frame)
|
|||
|
||||
x_dnd_waiting_for_finish = false;
|
||||
|
||||
if (x_dnd_use_toplevels)
|
||||
x_dnd_free_toplevels (true);
|
||||
|
||||
FRAME_DISPLAY_INFO (f)->grabbed = 0;
|
||||
#ifdef USE_GTK
|
||||
current_hold_quit = NULL;
|
||||
|
@ -10960,6 +10969,8 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
|
|||
x_dnd_free_toplevels (true);
|
||||
x_dnd_use_toplevels = false;
|
||||
}
|
||||
else
|
||||
record_unwind_protect_void (x_free_dnd_toplevels);
|
||||
}
|
||||
|
||||
if (!NILP (return_frame))
|
||||
|
@ -11132,10 +11143,6 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
|
|||
}
|
||||
|
||||
x_dnd_waiting_for_finish = false;
|
||||
|
||||
if (x_dnd_use_toplevels)
|
||||
x_dnd_free_toplevels (true);
|
||||
|
||||
x_dnd_return_frame_object = NULL;
|
||||
x_dnd_movement_frame = NULL;
|
||||
|
||||
|
@ -11223,10 +11230,6 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
|
|||
}
|
||||
|
||||
x_dnd_waiting_for_finish = false;
|
||||
|
||||
if (x_dnd_use_toplevels)
|
||||
x_dnd_free_toplevels (true);
|
||||
|
||||
x_dnd_return_frame_object = NULL;
|
||||
x_dnd_movement_frame = NULL;
|
||||
|
||||
|
@ -11287,9 +11290,6 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
|
|||
FRAME_DISPLAY_INFO (f)->Xatom_XdndSelection);
|
||||
unblock_input ();
|
||||
|
||||
if (x_dnd_use_toplevels)
|
||||
x_dnd_free_toplevels (true);
|
||||
|
||||
if (x_dnd_return_frame == 3
|
||||
&& FRAME_LIVE_P (x_dnd_return_frame_object))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue