Commit: b201a67faa350ef1f8f7a27997b82ec19551c11d
Author: Bastien Montagne
Date:   Fri Mar 6 15:19:32 2020 +0100
Branches: master
https://developer.blender.org/rBb201a67faa350ef1f8f7a27997b82ec19551c11d

Cleanup: bScreen: Move to IDTypeInfo and remove unused BKE API.

===================================================================

M       source/blender/blenkernel/BKE_idtype.h
M       source/blender/blenkernel/intern/idtype.c
M       source/blender/blenkernel/intern/lib_id_delete.c
M       source/blender/blenkernel/intern/screen.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_idtype.h 
b/source/blender/blenkernel/BKE_idtype.h
index 0baf4010a4f..356e059057e 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -139,7 +139,7 @@ extern IDTypeInfo IDType_ID_CA;
 // extern IDTypeInfo IDType_ID_IP;
 extern IDTypeInfo IDType_ID_KE;
 extern IDTypeInfo IDType_ID_WO;
-// extern IDTypeInfo IDType_ID_SCR;
+extern IDTypeInfo IDType_ID_SCR;
 // extern IDTypeInfo IDType_ID_VF;
 // extern IDTypeInfo IDType_ID_TXT;
 // extern IDTypeInfo IDType_ID_SPK;
diff --git a/source/blender/blenkernel/intern/idtype.c 
b/source/blender/blenkernel/intern/idtype.c
index 37449e89774..9de431a7f13 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -66,7 +66,7 @@ static void id_type_init(void)
   // INIT_TYPE(ID_IP);
   INIT_TYPE(ID_KE);
   INIT_TYPE(ID_WO);
-  // INIT_TYPE(ID_SCR);
+  INIT_TYPE(ID_SCR);
   // INIT_TYPE(ID_VF);
   // INIT_TYPE(ID_TXT);
   // INIT_TYPE(ID_SPK);
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c 
b/source/blender/blenkernel/intern/lib_id_delete.c
index 4292531d47a..a790207cebb 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -182,7 +182,7 @@ void BKE_libblock_free_datablock(ID *id, const int 
UNUSED(flag))
       BLI_assert(0);
       break;
     case ID_SCR:
-      BKE_screen_free((bScreen *)id);
+      BLI_assert(0);
       break;
     case ID_VF:
       BKE_vfont_free((VFont *)id);
diff --git a/source/blender/blenkernel/intern/screen.c 
b/source/blender/blenkernel/intern/screen.c
index 5e19a60dfa2..6285aee0ffa 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -43,11 +43,51 @@
 #include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
+#include "BLT_translation.h"
+
 #include "BKE_icons.h"
 #include "BKE_idprop.h"
+#include "BKE_idtype.h"
 #include "BKE_screen.h"
 #include "BKE_workspace.h"
 
+static void screen_free_data(ID *id)
+{
+  bScreen *screen = (bScreen *)id;
+  ARegion *ar;
+
+  /* No animdata here. */
+
+  for (ar = screen->regionbase.first; ar; ar = ar->next) {
+    BKE_area_region_free(NULL, ar);
+  }
+
+  BLI_freelistN(&screen->regionbase);
+
+  BKE_screen_area_map_free(AREAMAP_FROM_SCREEN(screen));
+
+  BKE_previewimg_free(&screen->preview);
+
+  /* Region and timer are freed by the window manager. */
+  MEM_SAFE_FREE(screen->tool_tip);
+}
+
+IDTypeInfo IDType_ID_SCR = {
+    .id_code = ID_SCR,
+    .id_filter = 0,
+    .main_listbase_index = INDEX_ID_SCR,
+    .struct_size = sizeof(bScreen),
+    .name = "Screen",
+    .name_plural = "screens",
+    .translation_context = BLT_I18NCONTEXT_ID_SCREEN,
+    .flags = IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_MAKELOCAL,
+
+    .init_data = NULL,
+    .copy_data = NULL,
+    .free_data = screen_free_data,
+    .make_local = NULL,
+};
+
 /* ************ Spacetype/regiontype handling ************** */
 
 /* keep global; this has to be accessible outside of windowmanager */
@@ -474,22 +514,7 @@ void BKE_screen_area_map_free(ScrAreaMap *area_map)
 /** Free (or release) any data used by this screen (does not free the screen 
itself). */
 void BKE_screen_free(bScreen *sc)
 {
-  ARegion *ar;
-
-  /* No animdata here. */
-
-  for (ar = sc->regionbase.first; ar; ar = ar->next) {
-    BKE_area_region_free(NULL, ar);
-  }
-
-  BLI_freelistN(&sc->regionbase);
-
-  BKE_screen_area_map_free(AREAMAP_FROM_SCREEN(sc));
-
-  BKE_previewimg_free(&sc->preview);
-
-  /* Region and timer are freed by the window manager. */
-  MEM_SAFE_FREE(sc->tool_tip);
+  screen_free_data(&sc->id);
 }
 
 /* ***************** Screen edges & verts ***************** */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to