[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59558] branches/soc-2013-ui_replay/source /blender: Not possible to add the same operator twice.
Vincent Akkermans
vincent at ack-err.net
Tue Aug 27 18:27:28 CEST 2013
Revision: 59558
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59558
Author: ack-err
Date: 2013-08-27 16:27:28 +0000 (Tue, 27 Aug 2013)
Log Message:
-----------
Not possible to add the same operator twice. Added checks for both drag & drop and the menu.
Modified Paths:
--------------
branches/soc-2013-ui_replay/source/blender/editors/screen/area.c
branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c
Modified: branches/soc-2013-ui_replay/source/blender/editors/screen/area.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/screen/area.c 2013-08-27 15:43:26 UTC (rev 59557)
+++ branches/soc-2013-ui_replay/source/blender/editors/screen/area.c 2013-08-27 16:27:28 UTC (rev 59558)
@@ -937,9 +937,6 @@
/* set here, assuming userpref switching forces to call this again */
ar->overlap = region_is_overlap(win, sa, ar);
-
- if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
- printf("yep, overlep!\n");
/* clear state flags first */
ar->flag &= ~RGN_FLAG_TOO_SMALL;
Modified: branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c 2013-08-27 15:43:26 UTC (rev 59557)
+++ branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c 2013-08-27 16:27:28 UTC (rev 59558)
@@ -4156,10 +4156,17 @@
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_MENU_BAR);
+ wmWindowManager *wm = CTX_wm_manager(C);
if (ar && arg1)
{
wmOperatorType *ot = (wmOperatorType*)arg1;
+
+ if (BLI_findstring(&ar->operators, ot->idname, offsetof(OperatorListItem, optype_idname))) {
+ BKE_reportf(&wm->reports, RPT_INFO, "This operator (%s) is already present in the menubar.", ot->idname);
+ return;
+ }
+
OperatorListItem *oli = MEM_callocN(sizeof(OperatorListItem), "add operator list item to icon shelf");
BLI_strncpy(oli->optype_idname, ot->idname, OP_MAX_TYPENAME);
@@ -4230,7 +4237,7 @@
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar;
- PanelType *pt_iter, *pt_new;
+ PanelType *pt_iter;
char *name = NULL;
int name_taken = 1;
@@ -4297,7 +4304,6 @@
char *opname = NULL, *panelid = NULL;
ARegion *ar;
ScrArea *sa = CTX_wm_area(C);
- PanelType *pt;
Panel *pa;
prop = RNA_struct_find_property(op->ptr, "operator");
@@ -4310,12 +4316,6 @@
// get panel
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
-// for (pt_iter = ar->type->paneltypes.first; pt_iter; pt_iter = pt_iter->next) {
-// if (strcmp(pt_iter->idname, panelid) == 0) {
-// pt = pt_iter;
-// break;
-// }
-// }
for (pa = ar->panels.first; pa; pa = pa->next) {
if (pa->type && strcmp(pa->type->idname, panelid) == 0) {
@@ -4323,13 +4323,17 @@
}
}
- if(pa == NULL) {
+ if (pa == NULL) {
MEM_freeN(opname);
MEM_freeN(panelid);
return OPERATOR_CANCELLED;
}
- // TODO: actually add the operator id string to the paneltype
+ if (BLI_findstring(&pa->operators, opname, offsetof(OperatorListItem, optype_idname))) {
+ BKE_reportf(op->reports, RPT_INFO, "This operator (%s) is already present in this panel (%s).", opname, pa->drawname);
+ return OPERATOR_CANCELLED;
+ }
+
uiPanelAddOperator(pa, opname);
MEM_freeN(opname);
More information about the Bf-blender-cvs
mailing list