+
+ ERROR_CHECK_SUBWINDOW_CACHE (p);
+}
+
+static int
+window_unmap_subwindows_cache_mapper (Lisp_Object key, Lisp_Object value,
+ void *flag_closure)
+{
+ /* value can be nil; we cache failures as well as successes */
+ if (!NILP (value))
+ {
+ struct frame* f = XFRAME (XIMAGE_INSTANCE_FRAME (value));
+ unmap_subwindow (value);
+ /* In case GC doesn't catch up fast enough, remove from the frame
+ cache also. Otherwise code that checks the sanity of the instance
+ will fail. */
+ XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))
+ = delq_no_quit (value, XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f)));
+ }
+ return 0;
+}
+
+static void
+window_unmap_subwindows (struct window* w)
+{
+ assert (!NILP (w->subwindow_instance_cache));
+ elisp_maphash (window_unmap_subwindows_cache_mapper,
+ w->subwindow_instance_cache, 0);