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.
diff --git a/src/gui.c b/src/gui.c
index 45bf49a..671f559 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -1124,7 +1124,7 @@
 			     shape->blinkoff);
 	if (shape->blinkwait == 0 || shape->blinkon == 0
 						       || shape->blinkoff == 0)
-	    gui_mch_stop_blink();
+	    gui_mch_stop_blink(FALSE);
 #ifdef FEAT_TERMINAL
 	if (shape_bg != INVALCOLOR)
 	{
@@ -2982,7 +2982,7 @@
 	 * for showmatch() */
 	gui_mch_start_blink();
 	retval = gui_wait_for_chars_or_timer(wtime);
-	gui_mch_stop_blink();
+	gui_mch_stop_blink(TRUE);
 	return retval;
     }
 
@@ -3029,7 +3029,7 @@
 	retval = gui_wait_for_chars_or_timer(-1L);
     }
 
-    gui_mch_stop_blink();
+    gui_mch_stop_blink(TRUE);
     return retval;
 }
 
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 83b98e1..ad51be6 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -893,14 +893,14 @@
  * Stop the cursor blinking.  Show the cursor if it wasn't shown.
  */
     void
-gui_mch_stop_blink(void)
+gui_mch_stop_blink(int may_call_gui_update_cursor)
 {
     if (blink_timer)
     {
 	timeout_remove(blink_timer);
 	blink_timer = 0;
     }
-    if (blink_state == BLINK_OFF)
+    if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
     {
 	gui_update_cursor(TRUE, FALSE);
 	gui_mch_flush();
@@ -975,7 +975,7 @@
 		   gpointer data UNUSED)
 {
     if (blink_state != BLINK_NONE)
-	gui_mch_stop_blink();
+	gui_mch_stop_blink(TRUE);
 
     return FALSE;
 }
@@ -1006,7 +1006,7 @@
     gui_focus_change(FALSE);
 
     if (blink_state != BLINK_NONE)
-	gui_mch_stop_blink();
+	gui_mch_stop_blink(TRUE);
 
     return TRUE;
 }
@@ -1145,7 +1145,7 @@
 
 #if GTK_CHECK_VERSION(3,0,0)
     is_key_pressed = TRUE;
-    gui_mch_stop_blink();
+    gui_mch_stop_blink(TRUE);
 #endif
 
     gui.event_time = event->time;
@@ -6677,7 +6677,7 @@
 	    if (gui.in_focus)
 		gui_mch_start_blink();
 	    else
-		gui_mch_stop_blink();
+		gui_mch_stop_blink(TRUE);
 	    focus = gui.in_focus;
 	}
 
diff --git a/src/gui_mac.c b/src/gui_mac.c
index 97cbf80..db9f959 100644
--- a/src/gui_mac.c
+++ b/src/gui_mac.c
@@ -5156,9 +5156,10 @@
  * Stop the cursor blinking.  Show the cursor if it wasn't shown.
  */
     void
-gui_mch_stop_blink(void)
+gui_mch_stop_blink(int may_call_gui_update_cursor)
 {
-    gui_update_cursor(TRUE, FALSE);
+    if (may_call_gui_update_cursor)
+	gui_update_cursor(TRUE, FALSE);
     /* TODO: TODO: TODO: TODO: */
 /*    gui_w32_rm_blink_timer();
     if (blink_state == BLINK_OFF)
diff --git a/src/gui_photon.c b/src/gui_photon.c
index faed61d..fcfb4f6 100644
--- a/src/gui_photon.c
+++ b/src/gui_photon.c
@@ -383,7 +383,7 @@
 	    else
 	    {
 		gui_focus_change(FALSE);
-		gui_mch_stop_blink();
+		gui_mch_stop_blink(TRUE);
 	    }
 	    break;
 
@@ -2273,11 +2273,11 @@
 }
 
     void
-gui_mch_stop_blink(void)
+gui_mch_stop_blink(int may_call_gui_update_cursor)
 {
     PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0);
 
-    if (blink_state == BLINK_OFF)
+    if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
 	gui_update_cursor(TRUE, FALSE);
 
     blink_state = BLINK_NONE;
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 074954a..67aa1fc 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -638,10 +638,10 @@
  * Stop the cursor blinking.  Show the cursor if it wasn't shown.
  */
     void
-gui_mch_stop_blink(void)
+gui_mch_stop_blink(int may_call_gui_update_cursor)
 {
     gui_mswin_rm_blink_timer();
-    if (blink_state == BLINK_OFF)
+    if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
     {
 	gui_update_cursor(TRUE, FALSE);
 	gui_mch_flush();
@@ -2111,7 +2111,7 @@
 	    if (gui.in_focus)
 		gui_mch_start_blink();
 	    else
-		gui_mch_stop_blink();
+		gui_mch_stop_blink(TRUE);
 	    focus = gui.in_focus;
 	}
 
diff --git a/src/gui_x11.c b/src/gui_x11.c
index ee48fb3..34d584e 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -2746,7 +2746,7 @@
 	    if (gui.in_focus)
 		gui_mch_start_blink();
 	    else
-		gui_mch_stop_blink();
+		gui_mch_stop_blink(TRUE);
 	    focus = gui.in_focus;
 	}
 
@@ -3105,14 +3105,14 @@
  * Stop the cursor blinking.  Show the cursor if it wasn't shown.
  */
     void
-gui_mch_stop_blink(void)
+gui_mch_stop_blink(int may_call_gui_update_cursor)
 {
     if (blink_timer != (XtIntervalId)0)
     {
 	XtRemoveTimeOut(blink_timer);
 	blink_timer = (XtIntervalId)0;
     }
-    if (blink_state == BLINK_OFF)
+    if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
 	gui_update_cursor(TRUE, FALSE);
     blink_state = BLINK_NONE;
 }
diff --git a/src/proto/gui_gtk_x11.pro b/src/proto/gui_gtk_x11.pro
index 51546ae..aea8d0b 100644
--- a/src/proto/gui_gtk_x11.pro
+++ b/src/proto/gui_gtk_x11.pro
@@ -4,7 +4,7 @@
 int gui_mch_is_blinking(void);
 int gui_mch_is_blink_off(void);
 void gui_mch_set_blinking(long waittime, long on, long off);
-void gui_mch_stop_blink(void);
+void gui_mch_stop_blink(int may_call_gui_update_cursor);
 void gui_mch_start_blink(void);
 int gui_mch_early_init_check(int give_message);
 int gui_mch_init_check(void);
@@ -25,7 +25,7 @@
 void gui_mch_unmaximize(void);
 void gui_mch_newfont(void);
 void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction);
-void gui_gtk_get_screen_size_of_win(GtkWidget *win, int *width, int *height);
+void gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height);
 void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
 void gui_mch_settitle(char_u *title, char_u *icon);
 void gui_mch_enable_menu(int showit);
diff --git a/src/proto/gui_mac.pro b/src/proto/gui_mac.pro
index c7ab982..011ef28 100644
--- a/src/proto/gui_mac.pro
+++ b/src/proto/gui_mac.pro
@@ -17,7 +17,7 @@
 int gui_mch_is_blinking(void);
 int gui_mch_is_blink_off(void);
 void gui_mch_set_blinking(long wait, long on, long off);
-void gui_mch_stop_blink(void);
+void gui_mch_stop_blink(int may_call_gui_update_cursor);
 void gui_mch_start_blink(void);
 void gui_mch_getmouse(int *x, int *y);
 void gui_mch_setmouse(int x, int y);
diff --git a/src/proto/gui_photon.pro b/src/proto/gui_photon.pro
index cfa735c..9fcc512 100644
--- a/src/proto/gui_photon.pro
+++ b/src/proto/gui_photon.pro
@@ -44,7 +44,7 @@
 int gui_mch_is_blink_off(void);
 void gui_mch_set_blinking(long wait, long on, long off);
 void gui_mch_start_blink(void);
-void gui_mch_stop_blink(void);
+void gui_mch_stop_blink(int may_call_gui_update_cursor);
 void gui_mch_beep(void);
 void gui_mch_flash(int msec);
 void gui_mch_flush(void);
diff --git a/src/proto/gui_w32.pro b/src/proto/gui_w32.pro
index 9690450..487549e 100644
--- a/src/proto/gui_w32.pro
+++ b/src/proto/gui_w32.pro
@@ -3,7 +3,7 @@
 int gui_mch_is_blinking(void);
 int gui_mch_is_blink_off(void);
 void gui_mch_set_blinking(long wait, long on, long off);
-void gui_mch_stop_blink(void);
+void gui_mch_stop_blink(int may_call_gui_update_cursor);
 void gui_mch_start_blink(void);
 LRESULT WINAPI vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
 void gui_mch_new_colors(void);
diff --git a/src/proto/gui_x11.pro b/src/proto/gui_x11.pro
index e490d0c..955f374 100644
--- a/src/proto/gui_x11.pro
+++ b/src/proto/gui_x11.pro
@@ -57,7 +57,7 @@
 int gui_mch_is_blinking(void);
 int gui_mch_is_blink_off(void);
 void gui_mch_set_blinking(long waittime, long on, long off);
-void gui_mch_stop_blink(void);
+void gui_mch_stop_blink(int may_call_gui_update_cursor);
 void gui_mch_start_blink(void);
 guicolor_T gui_mch_get_rgb(guicolor_T pixel);
 void gui_x11_callbacks(Widget textArea, Widget vimForm);
diff --git a/src/version.c b/src/version.c
index d6082df..ea5dbef 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1450,
+/**/
     1449,
 /**/
     1448,