Bugfix: Crash in Sequencer when trying to undo after using Grease Pencil
authorJoshua Leung <aligorith@gmail.com>
Mon, 11 Jun 2012 03:03:36 +0000 (03:03 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 11 Jun 2012 03:03:36 +0000 (03:03 +0000)
Grease Pencil data was not getting correctly relinked after file reload (for
undo)

source/blender/blenloader/intern/readfile.c

index fdaa8f5e1930af389577da26fbc1129d91685b2d..6cc81218a6b50cb23317461dfc4a7dc0b008a525 100644 (file)
@@ -5288,6 +5288,14 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                 */
                                                sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd);
                                        }
+                                       else if (sl->spacetype == SPACE_SEQ) {
+                                               SpaceSeq *sseq = (SpaceSeq *)sl;
+                                               
+                                               /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+                                                * so fingers crossed this works fine!
+                                                */
+                                               sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
+                                       }
                                        else if (sl->spacetype == SPACE_NLA) {
                                                SpaceNla *snla= (SpaceNla *)sl;
                                                bDopeSheet *ads= snla->ads;
@@ -5358,15 +5366,20 @@ static void lib_link_screen(FileData *fd, Main *main)
                                        }
                                        else if (sl->spacetype == SPACE_CLIP) {
                                                SpaceClip *sclip = (SpaceClip *)sl;
-
+                                               
                                                sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
                                                sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask);
-
+                                               
                                                sclip->scopes.track_search = NULL;
                                                sclip->scopes.track_preview = NULL;
                                                sclip->draw_context = NULL;
                                                sclip->scopes.ok = 0;
                                        }
+                                       else if (sl->spacetype == SPACE_LOGIC) {
+                                               SpaceLogic *slogic = (SpaceLogic *)sl;
+                                               
+                                               slogic->gpd = newlibadr_us(fd, sc->id.lib, slogic->gpd);
+                                       }
                                }
                        }
                        sc->id.flag -= LIB_NEEDLINK;
@@ -5559,6 +5572,14 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                         */
                                        sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, 1);
                                }
+                               else if (sl->spacetype == SPACE_SEQ) {
+                                       SpaceSeq *sseq = (SpaceSeq *)sl;
+                                       
+                                       /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+                                        * so assume that here we're doing for undo only...
+                                        */
+                                       sseq->gpd = restore_pointer_by_name(newmain, (ID *)sseq->gpd, 1);
+                               }
                                else if (sl->spacetype == SPACE_NLA) {
                                        SpaceNla *snla = (SpaceNla *)sl;
                                        bDopeSheet *ads = snla->ads;
@@ -5629,6 +5650,11 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                        
                                        sclip->scopes.ok = 0;
                                }
+                               else if (sl->spacetype == SPACE_LOGIC) {
+                                       SpaceLogic *slogic = (SpaceLogic *)sl;
+                                       
+                                       slogic->gpd = restore_pointer_by_name(newmain, (ID *)slogic->gpd, 1);
+                               }
                        }
                }
        }
@@ -5869,7 +5895,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                        }
                        else if (sl->spacetype == SPACE_LOGIC) {
                                SpaceLogic *slogic = (SpaceLogic *)sl;
-                                       
+                               
+                               /* XXX: this is new stuff, which shouldn't be directly linking to gpd... */
                                if (slogic->gpd) {
                                        slogic->gpd = newdataadr(fd, slogic->gpd);
                                        direct_link_gpencil(fd, slogic->gpd);