Blender  V2.93
wm_panel_type.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
27 #include <stdio.h>
28 
29 #include "BLI_sys_types.h"
30 
32 
33 #include "BLI_ghash.h"
34 #include "BLI_utildefines.h"
35 
36 #include "BKE_screen.h"
37 
38 #include "WM_api.h"
39 
41 
42 PanelType *WM_paneltype_find(const char *idname, bool quiet)
43 {
44  if (idname[0]) {
46  if (pt) {
47  return pt;
48  }
49  }
50 
51  if (!quiet) {
52  printf("search for unknown paneltype %s\n", idname);
53  }
54 
55  return NULL;
56 }
57 
59 {
61  return true;
62 }
63 
65 {
66  const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
67 
68  BLI_assert(ok);
70 }
71 
72 /* called on initialize WM_init() */
74 {
75  /* reserve size is set based on blender default setup */
76  g_paneltypes_hash = BLI_ghash_str_new_ex("g_paneltypes_hash gh", 512);
77 }
78 
80 {
82 }
#define BLI_assert(a)
Definition: BLI_assert.h:58
GHash * BLI_ghash_str_new_ex(const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:900
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:756
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:1008
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:803
#define UNUSED_VARS_NDEBUG(...)
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:241
static GHash * g_paneltypes_hash
Definition: wm_panel_type.c:40
bool WM_paneltype_add(PanelType *pt)
Definition: wm_panel_type.c:58
void WM_paneltype_init(void)
Definition: wm_panel_type.c:73
void WM_paneltype_remove(PanelType *pt)
Definition: wm_panel_type.c:64
PanelType * WM_paneltype_find(const char *idname, bool quiet)
Definition: wm_panel_type.c:42
void WM_paneltype_clear(void)
Definition: wm_panel_type.c:79