changeset 3282:eb240d50a4c0

Fixed a weird bug when switch views
author unexist
date Fri, 27 Apr 2018 11:46:33 +0200
parents 1507598a8b95
children ef3a87ece392
files src/subtle/view.c
diffstat 1 files changed, 22 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtle/view.c	Fri Feb 02 15:29:12 2018 +0100
+++ b/src/subtle/view.c	Fri Apr 27 11:46:33 2018 +0200
@@ -75,36 +75,39 @@
   s1  = SCREEN(subArrayGet(subtle->screens, screenid));
   vid = subArrayIndex(subtle->views, (void *)v);
 
-  /* Check if view is visible on any screen */
-  if(subtle->visible_views & (1L << (vid + 1)))
+  if(s1)
     {
-      /* This only makes sense with more than one screen
-       * otherwise just ignore that */
-      if(1 < subtle->screens->ndata)
+      /* Check if view is visible on any screen */
+      if(subtle->visible_views & (1L << (vid + 1)))
         {
-          int i;
-
-          /* Find screen with view and swap */
-          for(i = 0; i < subtle->screens->ndata; i++)
+          /* This only makes sense with more than one screen
+           * otherwise just ignore that */
+          if(1 < subtle->screens->ndata)
             {
-              SubScreen *s2 = SCREEN(subtle->screens->data[i]);
+              int i;
 
-              if(s2->viewid == vid)
+              /* Find screen with view and swap */
+              for(i = 0; i < subtle->screens->ndata; i++)
                 {
-                  if(swap)
+                  SubScreen *s2 = SCREEN(subtle->screens->data[i]);
+
+                  if(s2 && s2->viewid == vid)
                     {
-                      /* Swap views */
-                      s2->viewid = s1->viewid;
-                      s1->viewid = vid;
+                      if(swap)
+                        {
+                          /* Swap views */
+                          s2->viewid = s1->viewid;
+                          s1->viewid = vid;
+                        }
+                      else subScreenWarp(s2);
+
+                      break;
                     }
-                  else subScreenWarp(s2);
-
-                  break;
                 }
             }
         }
+      else s1->viewid = vid;
     }
-  else s1->viewid = vid;
 
   /* Finally configure and render */
   subScreenConfigure();