Fix for memory leak and perhaps other issues on switching space types
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 14 Dec 2008 13:59:34 +0000 (13:59 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 14 Dec 2008 13:59:34 +0000 (13:59 +0000)
in an area, the handlers (UI and keymap) were not removed.

source/blender/editors/screen/area.c

index 1097062c526b49230c957dfc616672f4efefa7ba..066b110e4570482b1d7a1fdc70c45b8aee4012d4 100644 (file)
@@ -504,13 +504,18 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
 /* *********** Space switching code, local now *********** */
 /* XXX make operator for this */
 
-static void newspace(ScrArea *sa, int type)
+static void newspace(bContext *C, ScrArea *sa, int type)
 {
        if(sa->spacetype != type) {
-               SpaceType *st= BKE_spacetype_from_id(type);
-               SpaceLink *slold= sa->spacedata.first;
+               SpaceType *st;
+               SpaceLink *slold;
                SpaceLink *sl;
-               
+
+               ED_area_exit(C, sa);
+
+               st= BKE_spacetype_from_id(type);
+               slold= sa->spacedata.first;
+
                sa->spacetype= type;
                sa->butspacetype= type;
                
@@ -594,7 +599,7 @@ static char *windowtype_pup(void)
 
 static void spacefunc(struct bContext *C, void *arg1, void *arg2)
 {
-       newspace(C->area, C->area->butspacetype);
+       newspace(C, C->area, C->area->butspacetype);
        WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
 }