Revision: 17852 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17852 Author: ton Date: 2008-12-14 18:25:46 +0100 (Sun, 14 Dec 2008)
Log Message: ----------- 2.5 Fix for crash on joining (previously splitted) areas. Reason was the stored regions in pushed 'spaces' not being copied. next: free running handlers on area join/split. Modified Paths: -------------- branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c branches/blender2.5/blender/source/blender/editors/include/ED_screen.h branches/blender2.5/blender/source/blender/editors/screen/area.c branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h =================================================================== --- branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h 2008-12-14 16:44:13 UTC (rev 17851) +++ branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h 2008-12-14 17:25:46 UTC (rev 17852) @@ -108,10 +108,6 @@ } ARegionType; -void BKE_screen_area_free(struct ScrArea *sa); -void BKE_area_region_free(struct ARegion *ar); -void free_screen(struct bScreen *sc); - /* spacetypes */ struct SpaceType *BKE_spacetype_from_id(int spaceid); const struct ListBase *BKE_spacetypes_list(void); @@ -122,5 +118,14 @@ void BKE_spacedata_freelist(ListBase *lb); void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); +/* area/regions */ +struct ARegion *BKE_area_region_copy(struct ARegion *ar); +void BKE_area_region_free(struct ARegion *ar); + +void BKE_screen_area_free(struct ScrArea *sa); + +void free_screen(struct bScreen *sc); + + #endif Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c =================================================================== --- branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c 2008-12-14 16:44:13 UTC (rev 17851) +++ branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c 2008-12-14 17:25:46 UTC (rev 17852) @@ -57,10 +57,9 @@ void BKE_spacetypes_free(void) { - SpaceType *st, *stn; + SpaceType *st; - for(st= spacetypes.first; st; st= stn) { - stn= st->next; + for(st= spacetypes.first; st; st= st->next) { spacetype_free(st); } @@ -102,16 +101,14 @@ void BKE_spacedata_freelist(ListBase *lb) { - SpaceLink *sl, *sln; - ARegion *ar, *arn; + SpaceLink *sl; + ARegion *ar; - for (sl= lb->first; sl; sl= sln) { + for (sl= lb->first; sl; sl= sl->next) { SpaceType *st= BKE_spacetype_from_id(sl->spacetype); - sln= sl->next; - /* regions for pushed spaces */ - for(ar=sl->regionbase.first; ar; ar=arn) { - arn= ar->next; + /* free regions for pushed spaces */ + for(ar=sl->regionbase.first; ar; ar=ar->next) { BKE_area_region_free(ar); } BLI_freelistN(&sl->regionbase); @@ -123,6 +120,37 @@ BLI_freelistN(lb); } +ARegion *BKE_area_region_copy(ARegion *ar) +{ + ARegion *newar= MEM_dupallocN(ar); + + newar->handlers.first= newar->handlers.last= NULL; + newar->uiblocks.first= newar->uiblocks.last= NULL; + newar->swinid= 0; + + /* XXX regiondata callback */ + if(ar->regiondata) + newar->regiondata= MEM_dupallocN(ar->regiondata); + + return newar; +} + + +/* from lb2 to lb1, lb1 is supposed to be free'd */ +static void region_copylist(ListBase *lb1, ListBase *lb2) +{ + ARegion *ar; + + /* to be sure */ + lb1->first= lb1->last= NULL; + + for(ar= lb2->first; ar; ar= ar->next) { + ARegion *arnew= BKE_area_region_copy(ar); + BLI_addtail(lb1, arnew); + } +} + + /* lb1 should be empty */ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2) { @@ -133,8 +161,13 @@ for (sl= lb2->first; sl; sl= sl->next) { SpaceType *st= BKE_spacetype_from_id(sl->spacetype); - if(st && st->duplicate) - BLI_addtail(lb1, st->duplicate(sl)); + if(st && st->duplicate) { + SpaceLink *slnew= st->duplicate(sl); + + BLI_addtail(lb1, slnew); + + region_copylist(&slnew->regionbase, &sl->regionbase); + } } } Modified: branches/blender2.5/blender/source/blender/editors/include/ED_screen.h =================================================================== --- branches/blender2.5/blender/source/blender/editors/include/ED_screen.h 2008-12-14 16:44:13 UTC (rev 17851) +++ branches/blender2.5/blender/source/blender/editors/include/ED_screen.h 2008-12-14 17:25:46 UTC (rev 17852) @@ -46,7 +46,6 @@ void ED_region_exit(struct bContext *C, struct ARegion *ar); void ED_region_pixelspace(const struct bContext *C, struct ARegion *ar); void ED_region_init(struct bContext *C, struct ARegion *ar); -ARegion *ED_region_copy(ARegion *ar); /* spaces */ void ED_spacetypes_init(void); Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/screen/area.c 2008-12-14 16:44:13 UTC (rev 17851) +++ branches/blender2.5/blender/source/blender/editors/screen/area.c 2008-12-14 17:25:46 UTC (rev 17852) @@ -431,21 +431,6 @@ } -ARegion *ED_region_copy(ARegion *ar) -{ - ARegion *newar= MEM_dupallocN(ar); - - newar->handlers.first= newar->handlers.last= NULL; - newar->uiblocks.first= newar->uiblocks.last= NULL; - newar->swinid= 0; - - /* XXX regiondata */ - if(ar->regiondata) - newar->regiondata= MEM_dupallocN(ar->regiondata); - - return newar; -} - /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */ /* area vertices were set */ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) @@ -485,11 +470,11 @@ } } - /* regions */ + /* regions... XXX */ BLI_freelistN(&sa1->regionbase); for(ar= sa2->regionbase.first; ar; ar= ar->next) { - ARegion *newar= ED_region_copy(ar); + ARegion *newar= BKE_area_region_copy(ar); BLI_addtail(&sa1->regionbase, newar); } Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c 2008-12-14 16:44:13 UTC (rev 17851) +++ branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c 2008-12-14 17:25:46 UTC (rev 17852) @@ -1208,7 +1208,7 @@ /* insert a region in the area region list */ static int region_split_exec(bContext *C, wmOperator *op) { - ARegion *newar= ED_region_copy(C->region); + ARegion *newar= BKE_area_region_copy(C->region); int dir= RNA_enum_get(op->ptr, "dir"); BLI_insertlinkafter(&C->area->regionbase, C->region, newar); Modified: branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c 2008-12-14 16:44:13 UTC (rev 17851) +++ branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c 2008-12-14 17:25:46 UTC (rev 17852) @@ -548,6 +548,10 @@ if(soutlinern->rnapath) soutlinern->rnapath= MEM_dupallocN(soutlinern->rnapath); + soutlinern->oops.first= soutlinern->oops.last= NULL; + soutlinern->tree.first= soutlinern->tree.last= NULL; + soutlinern->treestore= NULL; + return (SpaceLink *)soutlinern; } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs