mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 7.4.1873
Problem: When a callback adds a timer the GUI doesn't use it until later. (Ramel Eshed) Solution: Return early if a callback adds a timer.
This commit is contained in:
@@ -1101,6 +1101,7 @@ insert_timer(timer_T *timer)
|
|||||||
if (first_timer != NULL)
|
if (first_timer != NULL)
|
||||||
first_timer->tr_prev = timer;
|
first_timer->tr_prev = timer;
|
||||||
first_timer = timer;
|
first_timer = timer;
|
||||||
|
did_add_timer = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1635,6 +1635,10 @@ EXTERN int disable_char_avail_for_testing INIT(= 0);
|
|||||||
EXTERN int in_free_unref_items INIT(= FALSE);
|
EXTERN int in_free_unref_items INIT(= FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FEAT_TIMERS
|
||||||
|
EXTERN int did_add_timer INIT(= FALSE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Optional Farsi support. Include it here, so EXTERN and INIT are defined.
|
* Optional Farsi support. Include it here, so EXTERN and INIT are defined.
|
||||||
*/
|
*/
|
||||||
|
@@ -6538,12 +6538,12 @@ gui_mch_wait_for_chars(long wtime)
|
|||||||
int focus;
|
int focus;
|
||||||
guint timer;
|
guint timer;
|
||||||
static int timed_out;
|
static int timed_out;
|
||||||
|
int retval = FAIL;
|
||||||
|
|
||||||
timed_out = FALSE;
|
timed_out = FALSE;
|
||||||
|
|
||||||
/* this timeout makes sure that we will return if no characters arrived in
|
/* this timeout makes sure that we will return if no characters arrived in
|
||||||
* time */
|
* time */
|
||||||
|
|
||||||
if (wtime > 0)
|
if (wtime > 0)
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
timer = g_timeout_add((guint)wtime, input_timer_cb, &timed_out);
|
timer = g_timeout_add((guint)wtime, input_timer_cb, &timed_out);
|
||||||
@@ -6568,7 +6568,15 @@ gui_mch_wait_for_chars(long wtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MESSAGE_QUEUE
|
#ifdef MESSAGE_QUEUE
|
||||||
|
# ifdef FEAT_TIMERS
|
||||||
|
did_add_timer = FALSE;
|
||||||
|
# endif
|
||||||
parse_queued_messages();
|
parse_queued_messages();
|
||||||
|
# ifdef FEAT_TIMERS
|
||||||
|
if (did_add_timer)
|
||||||
|
/* Need to recompute the waiting time. */
|
||||||
|
goto theend;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -6582,13 +6590,8 @@ gui_mch_wait_for_chars(long wtime)
|
|||||||
/* Got char, return immediately */
|
/* Got char, return immediately */
|
||||||
if (input_available())
|
if (input_available())
|
||||||
{
|
{
|
||||||
if (timer != 0 && !timed_out)
|
retval = OK;
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
goto theend;
|
||||||
g_source_remove(timer);
|
|
||||||
#else
|
|
||||||
gtk_timeout_remove(timer);
|
|
||||||
#endif
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
} while (wtime < 0 || !timed_out);
|
} while (wtime < 0 || !timed_out);
|
||||||
|
|
||||||
@@ -6597,7 +6600,15 @@ gui_mch_wait_for_chars(long wtime)
|
|||||||
*/
|
*/
|
||||||
gui_mch_update();
|
gui_mch_update();
|
||||||
|
|
||||||
return FAIL;
|
theend:
|
||||||
|
if (timer != 0 && !timed_out)
|
||||||
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
|
g_source_remove(timer);
|
||||||
|
#else
|
||||||
|
gtk_timeout_remove(timer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2022,6 +2022,22 @@ gui_mch_update(void)
|
|||||||
process_message();
|
process_message();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_any_timer(void)
|
||||||
|
{
|
||||||
|
MSG msg;
|
||||||
|
|
||||||
|
if (s_wait_timer != 0 && !s_timed_out)
|
||||||
|
{
|
||||||
|
KillTimer(NULL, s_wait_timer);
|
||||||
|
|
||||||
|
/* Eat spurious WM_TIMER messages */
|
||||||
|
while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
|
||||||
|
;
|
||||||
|
s_wait_timer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GUI input routine called by gui_wait_for_chars(). Waits for a character
|
* GUI input routine called by gui_wait_for_chars(). Waits for a character
|
||||||
* from the keyboard.
|
* from the keyboard.
|
||||||
@@ -2073,6 +2089,9 @@ gui_mch_wait_for_chars(int wtime)
|
|||||||
s_need_activate = FALSE;
|
s_need_activate = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_TIMERS
|
||||||
|
did_add_timer = FALSE;
|
||||||
|
#endif
|
||||||
#ifdef MESSAGE_QUEUE
|
#ifdef MESSAGE_QUEUE
|
||||||
/* Check channel while waiting message. */
|
/* Check channel while waiting message. */
|
||||||
for (;;)
|
for (;;)
|
||||||
@@ -2098,15 +2117,7 @@ gui_mch_wait_for_chars(int wtime)
|
|||||||
|
|
||||||
if (input_available())
|
if (input_available())
|
||||||
{
|
{
|
||||||
if (s_wait_timer != 0 && !s_timed_out)
|
remove_any_timer();
|
||||||
{
|
|
||||||
KillTimer(NULL, s_wait_timer);
|
|
||||||
|
|
||||||
/* Eat spurious WM_TIMER messages */
|
|
||||||
while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
|
|
||||||
;
|
|
||||||
s_wait_timer = 0;
|
|
||||||
}
|
|
||||||
allow_scrollbar = FALSE;
|
allow_scrollbar = FALSE;
|
||||||
|
|
||||||
/* Clear pending mouse button, the release event may have been
|
/* Clear pending mouse button, the release event may have been
|
||||||
@@ -2117,6 +2128,15 @@ gui_mch_wait_for_chars(int wtime)
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_TIMERS
|
||||||
|
if (did_add_timer)
|
||||||
|
{
|
||||||
|
/* Need to recompute the waiting time. */
|
||||||
|
remove_any_timer();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
allow_scrollbar = FALSE;
|
allow_scrollbar = FALSE;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@@ -2368,7 +2368,7 @@ find_closest_color(Colormap colormap, XColor *colorPtr)
|
|||||||
|
|
||||||
for (i = 0; i < cmap_size; i++)
|
for (i = 0; i < cmap_size; i++)
|
||||||
colortable[i].pixel = (unsigned long)i;
|
colortable[i].pixel = (unsigned long)i;
|
||||||
XQueryColors (gui.dpy, colormap, colortable, cmap_size);
|
XQueryColors(gui.dpy, colormap, colortable, cmap_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the color that best approximates the desired one, then
|
* Find the color that best approximates the desired one, then
|
||||||
@@ -2793,6 +2793,7 @@ gui_mch_update(void)
|
|||||||
gui_mch_wait_for_chars(long wtime)
|
gui_mch_wait_for_chars(long wtime)
|
||||||
{
|
{
|
||||||
int focus;
|
int focus;
|
||||||
|
int retval = FAIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make this static, in case gui_x11_timer_cb is called after leaving
|
* Make this static, in case gui_x11_timer_cb is called after leaving
|
||||||
@@ -2828,7 +2829,15 @@ gui_mch_wait_for_chars(long wtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MESSAGE_QUEUE
|
#ifdef MESSAGE_QUEUE
|
||||||
|
# ifdef FEAT_TIMERS
|
||||||
|
did_add_timer = FALSE;
|
||||||
|
# endif
|
||||||
parse_queued_messages();
|
parse_queued_messages();
|
||||||
|
# ifdef FEAT_TIMERS
|
||||||
|
if (did_add_timer)
|
||||||
|
/* Need to recompute the waiting time. */
|
||||||
|
break;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2843,12 +2852,15 @@ gui_mch_wait_for_chars(long wtime)
|
|||||||
|
|
||||||
if (input_available())
|
if (input_available())
|
||||||
{
|
{
|
||||||
|
retval = OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (timer != (XtIntervalId)0 && !timed_out)
|
if (timer != (XtIntervalId)0 && !timed_out)
|
||||||
XtRemoveTimeOut(timer);
|
XtRemoveTimeOut(timer);
|
||||||
return OK;
|
|
||||||
}
|
return retval;
|
||||||
}
|
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1873,
|
||||||
/**/
|
/**/
|
||||||
1872,
|
1872,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user