Skip to content

Commit 1dd45fb

Browse files
committed
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Problem: Endless loop when gui_mch_stop_blink() is called while blink_state is BLINK_OFF. (zdohnal) Solution: Avoid calling gui_update_cursor() recursively.
1 parent a338adc commit 1dd45fb

12 files changed

Lines changed: 29 additions & 26 deletions

File tree

src/gui.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ gui_update_cursor(
11241124
shape->blinkoff);
11251125
if (shape->blinkwait == 0 || shape->blinkon == 0
11261126
|| shape->blinkoff == 0)
1127-
gui_mch_stop_blink();
1127+
gui_mch_stop_blink(FALSE);
11281128
#ifdef FEAT_TERMINAL
11291129
if (shape_bg != INVALCOLOR)
11301130
{
@@ -2982,7 +2982,7 @@ gui_wait_for_chars(long wtime, int tb_change_cnt)
29822982
* for showmatch() */
29832983
gui_mch_start_blink();
29842984
retval = gui_wait_for_chars_or_timer(wtime);
2985-
gui_mch_stop_blink();
2985+
gui_mch_stop_blink(TRUE);
29862986
return retval;
29872987
}
29882988

@@ -3029,7 +3029,7 @@ gui_wait_for_chars(long wtime, int tb_change_cnt)
30293029
retval = gui_wait_for_chars_or_timer(-1L);
30303030
}
30313031

3032-
gui_mch_stop_blink();
3032+
gui_mch_stop_blink(TRUE);
30333033
return retval;
30343034
}
30353035

src/gui_gtk_x11.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,14 +893,14 @@ gui_mch_set_blinking(long waittime, long on, long off)
893893
* Stop the cursor blinking. Show the cursor if it wasn't shown.
894894
*/
895895
void
896-
gui_mch_stop_blink(void)
896+
gui_mch_stop_blink(int may_call_gui_update_cursor)
897897
{
898898
if (blink_timer)
899899
{
900900
timeout_remove(blink_timer);
901901
blink_timer = 0;
902902
}
903-
if (blink_state == BLINK_OFF)
903+
if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
904904
{
905905
gui_update_cursor(TRUE, FALSE);
906906
gui_mch_flush();
@@ -975,7 +975,7 @@ leave_notify_event(GtkWidget *widget UNUSED,
975975
gpointer data UNUSED)
976976
{
977977
if (blink_state != BLINK_NONE)
978-
gui_mch_stop_blink();
978+
gui_mch_stop_blink(TRUE);
979979

980980
return FALSE;
981981
}
@@ -1006,7 +1006,7 @@ focus_out_event(GtkWidget *widget UNUSED,
10061006
gui_focus_change(FALSE);
10071007

10081008
if (blink_state != BLINK_NONE)
1009-
gui_mch_stop_blink();
1009+
gui_mch_stop_blink(TRUE);
10101010

10111011
return TRUE;
10121012
}
@@ -1145,7 +1145,7 @@ key_press_event(GtkWidget *widget UNUSED,
11451145

11461146
#if GTK_CHECK_VERSION(3,0,0)
11471147
is_key_pressed = TRUE;
1148-
gui_mch_stop_blink();
1148+
gui_mch_stop_blink(TRUE);
11491149
#endif
11501150

11511151
gui.event_time = event->time;
@@ -6677,7 +6677,7 @@ gui_mch_wait_for_chars(long wtime)
66776677
if (gui.in_focus)
66786678
gui_mch_start_blink();
66796679
else
6680-
gui_mch_stop_blink();
6680+
gui_mch_stop_blink(TRUE);
66816681
focus = gui.in_focus;
66826682
}
66836683

src/gui_mac.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5156,9 +5156,10 @@ gui_mch_set_blinking(long wait, long on, long off)
51565156
* Stop the cursor blinking. Show the cursor if it wasn't shown.
51575157
*/
51585158
void
5159-
gui_mch_stop_blink(void)
5159+
gui_mch_stop_blink(int may_call_gui_update_cursor)
51605160
{
5161-
gui_update_cursor(TRUE, FALSE);
5161+
if (may_call_gui_update_cursor)
5162+
gui_update_cursor(TRUE, FALSE);
51625163
/* TODO: TODO: TODO: TODO: */
51635164
/* gui_w32_rm_blink_timer();
51645165
if (blink_state == BLINK_OFF)

src/gui_photon.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
383383
else
384384
{
385385
gui_focus_change(FALSE);
386-
gui_mch_stop_blink();
386+
gui_mch_stop_blink(TRUE);
387387
}
388388
break;
389389

@@ -2273,11 +2273,11 @@ gui_mch_start_blink(void)
22732273
}
22742274

22752275
void
2276-
gui_mch_stop_blink(void)
2276+
gui_mch_stop_blink(int may_call_gui_update_cursor)
22772277
{
22782278
PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0);
22792279

2280-
if (blink_state == BLINK_OFF)
2280+
if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
22812281
gui_update_cursor(TRUE, FALSE);
22822282

22832283
blink_state = BLINK_NONE;

src/gui_w32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,10 @@ gui_mswin_rm_blink_timer(void)
638638
* Stop the cursor blinking. Show the cursor if it wasn't shown.
639639
*/
640640
void
641-
gui_mch_stop_blink(void)
641+
gui_mch_stop_blink(int may_call_gui_update_cursor)
642642
{
643643
gui_mswin_rm_blink_timer();
644-
if (blink_state == BLINK_OFF)
644+
if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
645645
{
646646
gui_update_cursor(TRUE, FALSE);
647647
gui_mch_flush();
@@ -2111,7 +2111,7 @@ gui_mch_wait_for_chars(int wtime)
21112111
if (gui.in_focus)
21122112
gui_mch_start_blink();
21132113
else
2114-
gui_mch_stop_blink();
2114+
gui_mch_stop_blink(TRUE);
21152115
focus = gui.in_focus;
21162116
}
21172117

src/gui_x11.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,7 +2746,7 @@ gui_mch_wait_for_chars(long wtime)
27462746
if (gui.in_focus)
27472747
gui_mch_start_blink();
27482748
else
2749-
gui_mch_stop_blink();
2749+
gui_mch_stop_blink(TRUE);
27502750
focus = gui.in_focus;
27512751
}
27522752

@@ -3105,14 +3105,14 @@ gui_mch_set_blinking(long waittime, long on, long off)
31053105
* Stop the cursor blinking. Show the cursor if it wasn't shown.
31063106
*/
31073107
void
3108-
gui_mch_stop_blink(void)
3108+
gui_mch_stop_blink(int may_call_gui_update_cursor)
31093109
{
31103110
if (blink_timer != (XtIntervalId)0)
31113111
{
31123112
XtRemoveTimeOut(blink_timer);
31133113
blink_timer = (XtIntervalId)0;
31143114
}
3115-
if (blink_state == BLINK_OFF)
3115+
if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
31163116
gui_update_cursor(TRUE, FALSE);
31173117
blink_state = BLINK_NONE;
31183118
}

src/proto/gui_gtk_x11.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ void gui_mch_free_all(void);
44
int gui_mch_is_blinking(void);
55
int gui_mch_is_blink_off(void);
66
void gui_mch_set_blinking(long waittime, long on, long off);
7-
void gui_mch_stop_blink(void);
7+
void gui_mch_stop_blink(int may_call_gui_update_cursor);
88
void gui_mch_start_blink(void);
99
int gui_mch_early_init_check(int give_message);
1010
int gui_mch_init_check(void);
@@ -25,7 +25,7 @@ int gui_mch_maximized(void);
2525
void gui_mch_unmaximize(void);
2626
void gui_mch_newfont(void);
2727
void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction);
28-
void gui_gtk_get_screen_size_of_win(GtkWidget *win, int *width, int *height);
28+
void gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height);
2929
void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
3030
void gui_mch_settitle(char_u *title, char_u *icon);
3131
void gui_mch_enable_menu(int showit);

src/proto/gui_mac.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ short gui_mch_get_mac_menu_item_index(vimmenu_T *menu, vimmenu_T *parent);
1717
int gui_mch_is_blinking(void);
1818
int gui_mch_is_blink_off(void);
1919
void gui_mch_set_blinking(long wait, long on, long off);
20-
void gui_mch_stop_blink(void);
20+
void gui_mch_stop_blink(int may_call_gui_update_cursor);
2121
void gui_mch_start_blink(void);
2222
void gui_mch_getmouse(int *x, int *y);
2323
void gui_mch_setmouse(int x, int y);

src/proto/gui_photon.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int gui_mch_is_blinking(void);
4444
int gui_mch_is_blink_off(void);
4545
void gui_mch_set_blinking(long wait, long on, long off);
4646
void gui_mch_start_blink(void);
47-
void gui_mch_stop_blink(void);
47+
void gui_mch_stop_blink(int may_call_gui_update_cursor);
4848
void gui_mch_beep(void);
4949
void gui_mch_flash(int msec);
5050
void gui_mch_flush(void);

src/proto/gui_w32.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ int gui_mch_set_rendering_options(char_u *s);
33
int gui_mch_is_blinking(void);
44
int gui_mch_is_blink_off(void);
55
void gui_mch_set_blinking(long wait, long on, long off);
6-
void gui_mch_stop_blink(void);
6+
void gui_mch_stop_blink(int may_call_gui_update_cursor);
77
void gui_mch_start_blink(void);
88
LRESULT WINAPI vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
99
void gui_mch_new_colors(void);

0 commit comments

Comments
 (0)