]> git.eshelyaron.com Git - emacs.git/commitdiff
Check for existence of terminal hooks before use
authorAlexander Gramiak <agrambot@gmail.com>
Mon, 15 Apr 2019 17:33:19 +0000 (11:33 -0600)
committerAlexander Gramiak <agrambot@gmail.com>
Fri, 26 Apr 2019 22:55:39 +0000 (16:55 -0600)
This should not be necessary, and is merely a precaution. For
background, see:
https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00639.html

* src/frame.c:
* src/xdisp.c: Check for existence of terminal hooks before use.

src/frame.c
src/frame.h
src/xdisp.c

index 22a79859454c7531721a32eeb11b1cbec5348509..328facd2d5bb6f9dbed1b5cd64a47d00ff02a73d 100644 (file)
@@ -482,7 +482,8 @@ keep_ratio (struct frame *f, struct frame *p, int old_width, int old_height,
              f->top_pos = pos_y;
            }
 
-         FRAME_TERMINAL (f)->set_frame_offset_hook (f, pos_x, pos_y, -1);
+          if (FRAME_TERMINAL (f)->set_frame_offset_hook)
+            FRAME_TERMINAL (f)->set_frame_offset_hook (f, pos_x, pos_y, -1);
        }
 
       if (!CONSP (keep_ratio) || !NILP (Fcar (keep_ratio)))
@@ -669,11 +670,12 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
         list2 (inhibit_horizontal ? Qt : Qnil,
                inhibit_vertical ? Qt : Qnil));
 
-      FRAME_TERMINAL (f)->set_window_size_hook (f,
-                                                0,
-                                                new_text_width,
-                                                new_text_height,
-                                                1);
+      if (FRAME_TERMINAL (f)->set_window_size_hook)
+        FRAME_TERMINAL (f)->set_window_size_hook (f,
+                                                  0,
+                                                  new_text_width,
+                                                  new_text_height,
+                                                  1);
       f->resized_p = true;
 
       return;
@@ -1370,7 +1372,7 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
 #else /* ! 0 */
   /* Instead, apply it only to the frame we're pointing to.  */
 #ifdef HAVE_WINDOW_SYSTEM
-  if (track && FRAME_WINDOW_P (f))
+  if (track && FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->get_focus_frame)
     {
       Lisp_Object focus, gfocus;
 
@@ -2836,7 +2838,7 @@ If there is no window system support, this function does nothing.  */)
 {
 #ifdef HAVE_WINDOW_SYSTEM
   struct frame *f = decode_window_system_frame (frame);
-  if (f)
+  if (f && FRAME_TERMINAL (f)->focus_frame_hook)
     FRAME_TERMINAL (f)->focus_frame_hook (f, !NILP (noactivate));
 #endif
   return Qnil;
@@ -3602,10 +3604,11 @@ bottom edge of FRAME's display.  */)
   if (FRAME_WINDOW_P (f))
     {
 #ifdef HAVE_WINDOW_SYSTEM
-      FRAME_TERMINAL (f)->set_frame_offset_hook (f,
-                                                 XFIXNUM (x),
-                                                 XFIXNUM (y),
-                                                 1);
+      if (FRAME_TERMINAL (f)->set_frame_offset_hook)
+        FRAME_TERMINAL (f)->set_frame_offset_hook (f,
+                                                   XFIXNUM (x),
+                                                   XFIXNUM (y),
+                                                   1);
 #endif
     }
 
@@ -4161,7 +4164,8 @@ gui_set_frame_parameters (struct frame *f, Lisp_Object alist)
       f->win_gravity = NorthWestGravity;
 
       /* Actually set that position, and convert to absolute.  */
-      FRAME_TERMINAL (f)->set_frame_offset_hook (f, leftpos, toppos, -1);
+      if (FRAME_TERMINAL (f)->set_frame_offset_hook)
+        FRAME_TERMINAL (f)->set_frame_offset_hook (f, leftpos, toppos, -1);
     }
 
   if (fullscreen_change)
@@ -4436,7 +4440,8 @@ gui_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   if (! NILP (Fequal (font_object, oldval)))
     return;
 
-  FRAME_TERMINAL (f)->set_new_font_hook (f, font_object, fontset);
+  if (FRAME_TERMINAL (f)->set_new_font_hook)
+    FRAME_TERMINAL (f)->set_new_font_hook (f, font_object, fontset);
   store_frame_param (f, Qfont, arg);
 #ifdef HAVE_X_WINDOWS
   store_frame_param (f, Qfont_parameter, font_param);
@@ -4716,7 +4721,8 @@ gui_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
     }
   else
     {
-      FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f);
+      if (FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook)
+        FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f);
 
       if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
@@ -4746,7 +4752,8 @@ gui_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
     }
   else
     {
-      FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f);
+      if (FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook)
+        FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f);
 
       if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
index e66590ef74ff4d62f83fe7eb1f16c8cb89b34f21..70597737d49498abd92d879b2f95157eb9c0f8e1 100644 (file)
@@ -1602,7 +1602,8 @@ gui_set_bitmap_icon (struct frame *f)
 {
   Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
 
-  if (CONSP (obj) && !NILP (XCDR (obj)))
+  if (CONSP (obj) && !NILP (XCDR (obj))
+      && FRAME_TERMINAL (f)->set_bitmap_icon_hook)
     FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, XCDR (obj));
 }
 
index 19fbf93dd08fe0eefb22daaf942f754bd9c893a2..34e89c79046ff44893902bd5428c805aa670d760 100644 (file)
@@ -12077,9 +12077,10 @@ gui_consider_frame_title (Lisp_Object frame)
         already wasted too much time by walking through the list with
         display_mode_element, then we might need to optimize at a
         higher level than this.)  */
-      if (! STRINGP (f->name)
-         || SBYTES (f->name) != len
-         || memcmp (title, SDATA (f->name), len) != 0)
+      if ((! STRINGP (f->name)
+           || SBYTES (f->name) != len
+           || memcmp (title, SDATA (f->name), len) != 0)
+          && FRAME_TERMINAL (f)->implicit_set_name_hook)
        FRAME_TERMINAL (f)->implicit_set_name_hook (f,
                                                     make_string (title, len),
                                                     Qnil);
@@ -12856,7 +12857,8 @@ redisplay_tool_bar (struct frame *f)
 
       if (new_height != WINDOW_PIXEL_HEIGHT (w))
        {
-         FRAME_TERMINAL (f)->change_tool_bar_height_hook (f, new_height);
+          if (FRAME_TERMINAL (f)->change_tool_bar_height_hook)
+            FRAME_TERMINAL (f)->change_tool_bar_height_hook (f, new_height);
          frame_default_tool_bar_height = new_height;
          /* Always do that now.  */
          clear_glyph_matrix (w->desired_matrix);
@@ -12951,7 +12953,8 @@ redisplay_tool_bar (struct frame *f)
 
          if (change_height_p)
            {
-             FRAME_TERMINAL (f)->change_tool_bar_height_hook (f, new_height);
+              if (FRAME_TERMINAL (f)->change_tool_bar_height_hook)
+                FRAME_TERMINAL (f)->change_tool_bar_height_hook (f, new_height);
              frame_default_tool_bar_height = new_height;
              clear_glyph_matrix (w->desired_matrix);
              f->n_tool_bar_rows = nrows;