Ejemplo n.º 1
0
static IDProperty *idp_from_PyMapping(const char *name, PyObject *ob)
{
	IDProperty *prop;
	IDPropertyTemplate val = {0};

	PyObject *keys, *vals, *key, *pval;
	int i, len;
	/* yay! we get into recursive stuff now! */
	keys = PyMapping_Keys(ob);
	vals = PyMapping_Values(ob);

	/* we allocate the group first; if we hit any invalid data,
	 * we can delete it easily enough.*/
	prop = IDP_New(IDP_GROUP, &val, name);
	len = PyMapping_Length(ob);
	for (i = 0; i < len; i++) {
		key = PySequence_GetItem(keys, i);
		pval = PySequence_GetItem(vals, i);
		if (BPy_IDProperty_Map_ValidateAndCreate(key, prop, pval) == false) {
			IDP_FreeProperty(prop);
			MEM_freeN(prop);
			Py_XDECREF(keys);
			Py_XDECREF(vals);
			Py_XDECREF(key);
			Py_XDECREF(pval);
			/* error is already set */
			return NULL;
		}
		Py_XDECREF(key);
		Py_XDECREF(pval);
	}
	Py_XDECREF(keys);
	Py_XDECREF(vals);
	return prop;
}
Ejemplo n.º 2
0
static wmKeyMapItem *wm_keymap_item_find(
        const bContext *C, const char *opname, int opcontext,
        IDProperty *properties, const short hotkey, const bool strict, wmKeyMap **keymap_r)
{
	wmKeyMapItem *found = wm_keymap_item_find_props(C, opname, opcontext, properties, strict, hotkey, keymap_r);

	if (!found && properties) {
		wmOperatorType *ot = WM_operatortype_find(opname, TRUE);
		if (ot) {
			/* make a copy of the properties and set any unset props
			 * to their default values, so the ID property compare function succeeds */
			PointerRNA opptr;
			IDProperty *properties_default = IDP_CopyProperty(properties);

			RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);

			if (WM_operator_properties_default(&opptr, true) ||
			    (!strict && ot->prop && RNA_property_is_set(&opptr, ot->prop)))
			{
				/* for operator that has enum menu, unset it so it always matches */
				if (!strict && ot->prop) {
					RNA_property_unset(&opptr, ot->prop);
				}

				found = wm_keymap_item_find_props(C, opname, opcontext, properties_default, false, hotkey, keymap_r);
			}

			IDP_FreeProperty(properties_default);
			MEM_freeN(properties_default);
		}
	}

	return found;
}
Ejemplo n.º 3
0
void BKE_libblock_free_data(Main *UNUSED(bmain), ID *id)
{
	if (id->properties) {
		IDP_FreeProperty(id->properties);
		MEM_freeN(id->properties);
	}
}
Ejemplo n.º 4
0
void IMB_metadata_free(struct IDProperty *metadata)
{
  if (metadata == NULL) {
    return;
  }

  IDP_FreeProperty(metadata);
}
Ejemplo n.º 5
0
static void fcm_python_free(FModifier *fcm)
{
	FMod_Python *data = (FMod_Python *)fcm->data;
	
	/* id-properties */
	IDP_FreeProperty(data->prop);
	MEM_freeN(data->prop);
}
Ejemplo n.º 6
0
void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
{
	wmWindowManager *wm = CTX_wm_manager(C);
	wmKeyMap *defaultmap, *addonmap;
	wmKeyMapItem *orig;

	if(!keymap)
		return;

	/* construct default keymap from preset + addons */
	defaultmap= wm_keymap_preset(wm, keymap);
	addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);

	if(addonmap) {
		defaultmap = wm_keymap_copy(defaultmap);
		wm_keymap_addon_add(defaultmap, addonmap);
	}

	/* find original item */
	orig = WM_keymap_item_find_id(defaultmap, kmi->id);

	if(orig) {
		/* restore to original */
		if(strcmp(orig->idname, kmi->idname) != 0) {
			BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
			WM_keymap_properties_reset(kmi, NULL);
		}

		if (orig->properties) {
			if(kmi->properties) {
				IDP_FreeProperty(kmi->properties);
				MEM_freeN(kmi->properties);
				kmi->properties= NULL;
			}

			kmi->properties= IDP_CopyProperty(orig->properties);
			kmi->ptr->data= kmi->properties;
		}

		kmi->propvalue = orig->propvalue;
		kmi->type = orig->type;
		kmi->val = orig->val;
		kmi->shift = orig->shift;
		kmi->ctrl = orig->ctrl;
		kmi->alt = orig->alt;
		kmi->oskey = orig->oskey;
		kmi->keymodifier = orig->keymodifier;
		kmi->maptype = orig->maptype;

		WM_keyconfig_update_tag(keymap, kmi);
	}

	/* free temporary keymap */
	if(addonmap) {
		WM_keymap_free(defaultmap);
		MEM_freeN(defaultmap);
	}
}
Ejemplo n.º 7
0
/**
 * Override values in in-memory startup.blend, avoids resaving for small changes.
 */
void BLO_update_defaults_userpref_blend(void)
{
  /* default so DPI is detected automatically */
  U.dpi = 0;
  U.ui_scale = 1.0f;

#ifdef WITH_PYTHON_SECURITY
  /* use alternative setting for security nuts
   * otherwise we'd need to patch the binary blob - startup.blend.c */
  U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
#else
  U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
#endif

  /* Transform tweak with single click and drag. */
  U.flag |= USER_RELEASECONFIRM;

  U.flag &= ~(USER_DEVELOPER_UI | USER_TOOLTIPS_PYTHON);

  /* Clear addon preferences. */
  for (bAddon *addon = U.addons.first, *addon_next; addon != NULL; addon = addon_next) {
    addon_next = addon->next;

    if (addon->prop) {
      IDP_FreeProperty(addon->prop);
      MEM_freeN(addon->prop);
      addon->prop = NULL;
    }
  }

  /* Ignore the theme saved in the blend file,
   * instead use the theme from 'userdef_default_theme.c' */
  {
    bTheme *theme = U.themes.first;
    memcpy(theme, &U_theme_default, sizeof(bTheme));
  }

  /* Leave temp directory empty, will then get appropriate value per OS. */
  U.tempdir[0] = '\0';

  /* Only enable tooltips translation by default,
   * without actually enabling translation itself, for now. */
  U.transopts = USER_TR_TOOLTIPS;
  U.memcachelimit = 4096;

  /* Auto perspective. */
  U.uiflag |= USER_AUTOPERSP;

  /* Init weight paint range. */
  BKE_colorband_init(&U.coba_weight, true);

  /* Default visible section. */
  U.userpref = USER_SECTION_INTERFACE;

  /* Default to left click select. */
  BKE_keyconfig_pref_set_select_mouse(&U, 0, true);
}
Ejemplo n.º 8
0
static void keymap_item_free(wmKeyMapItem *kmi)
{
	if (kmi->properties) {
		IDP_FreeProperty(kmi->properties);
		MEM_freeN(kmi->properties);
	}
	if (kmi->ptr)
		MEM_freeN(kmi->ptr);
}
Ejemplo n.º 9
0
void BKE_blender_user_menu_item_free(bUserMenuItem *umi)
{
  if (umi->type == USER_MENU_TYPE_OPERATOR) {
    bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
    if (umi_op->prop) {
      IDP_FreeProperty(umi_op->prop);
    }
  }
  MEM_freeN(umi);
}
Ejemplo n.º 10
0
void BKE_libblock_free_data(Main *bmain, ID *id)
{
	if (id->properties) {
		IDP_FreeProperty(id->properties);
		MEM_freeN(id->properties);
	}
	
	/* this ID may be a driver target! */
	BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id);
}
Ejemplo n.º 11
0
static void ffmpeg_set_expert_options(RenderData *rd)
{
	int codec_id = rd->ffcodecdata.codec;

	if (rd->ffcodecdata.properties)
		IDP_FreeProperty(rd->ffcodecdata.properties);

	if (codec_id == CODEC_ID_H264) {
		/*
		 * All options here are for x264, but must be set via ffmpeg.
		 * The names are therefore different - Search for "x264 to FFmpeg option mapping"
		 * to get a list.
		 */

		/*
		 * Use CABAC coder. Using "coder:1", which should be equivalent,
		 * crashes Blender for some reason. Either way - this is no big deal.
		 */
		BKE_ffmpeg_property_add_string(rd, "video", "coder:vlc");

		/*
		 * The other options were taken from the libx264-default.preset
		 * included in the ffmpeg distribution.
		 */
//		ffmpeg_property_add_string(rd, "video", "flags:loop"); // this breaks compatibility for QT
		BKE_ffmpeg_property_add_string(rd, "video", "cmp:chroma");
		BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4");
		BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8");
		BKE_ffmpeg_property_add_string(rd, "video", "partitions:partb8x8");
		BKE_ffmpeg_property_add_string(rd, "video", "me:hex");
		BKE_ffmpeg_property_add_string(rd, "video", "subq:6");
		BKE_ffmpeg_property_add_string(rd, "video", "me_range:16");
		BKE_ffmpeg_property_add_string(rd, "video", "qdiff:4");
		BKE_ffmpeg_property_add_string(rd, "video", "keyint_min:25");
		BKE_ffmpeg_property_add_string(rd, "video", "sc_threshold:40");
		BKE_ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71");
		BKE_ffmpeg_property_add_string(rd, "video", "b_strategy:1");
		BKE_ffmpeg_property_add_string(rd, "video", "bf:3");
		BKE_ffmpeg_property_add_string(rd, "video", "refs:2");
		BKE_ffmpeg_property_add_string(rd, "video", "qcomp:0.6");
		BKE_ffmpeg_property_add_string(rd, "video", "directpred:3");
		BKE_ffmpeg_property_add_string(rd, "video", "trellis:0");
		BKE_ffmpeg_property_add_string(rd, "video", "flags2:wpred");
		BKE_ffmpeg_property_add_string(rd, "video", "flags2:dct8x8");
		BKE_ffmpeg_property_add_string(rd, "video", "flags2:fastpskip");
		BKE_ffmpeg_property_add_string(rd, "video", "wpredp:2");

		if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
			BKE_ffmpeg_property_add_string(rd, "video", "cqp:0");
	}
	else if (codec_id == CODEC_ID_DNXHD) {
		if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
			BKE_ffmpeg_property_add_string(rd, "video", "mbd:rd");
	}
}
Ejemplo n.º 12
0
static void userdef_free_keyconfig_prefs(UserDef *userdef)
{
  for (wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first, *kpt_next; kpt;
       kpt = kpt_next) {
    kpt_next = kpt->next;
    IDP_FreeProperty(kpt->prop);
    MEM_freeN(kpt->prop);
    MEM_freeN(kpt);
  }
  BLI_listbase_clear(&userdef->user_keyconfig_prefs);
}
Ejemplo n.º 13
0
static void userdef_free_addons(UserDef *userdef)
{
	for (bAddon *addon = userdef->addons.first, *addon_next; addon; addon = addon_next) {
		addon_next = addon->next;
		if (addon->prop) {
			IDP_FreeProperty(addon->prop);
			MEM_freeN(addon->prop);
		}
		MEM_freeN(addon);
	}
	BLI_listbase_clear(&userdef->addons);
}
Ejemplo n.º 14
0
void BKE_libblock_free_data(ID *id)
{
	Main *bmain = G.main;  /* should eventually be an arg */
	
	if (id->properties) {
		IDP_FreeProperty(id->properties);
		MEM_freeN(id->properties);
	}
	
	/* this ID may be a driver target! */
	BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id);
}
Ejemplo n.º 15
0
/* not region itself */
void BKE_area_region_free(SpaceType *st, ARegion *ar)
{
	uiList *uilst;

	if (st) {
		ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
		
		if (art && art->free)
			art->free(ar);
		
		if (ar->regiondata)
			printf("regiondata free error\n");
	}
	else if (ar->type && ar->type->free)
		ar->type->free(ar);
	
	if (ar->v2d.tab_offset) {
		MEM_freeN(ar->v2d.tab_offset);
		ar->v2d.tab_offset = NULL;
	}

	if (!BLI_listbase_is_empty(&ar->panels)) {
		Panel *pa, *pa_next;
		for (pa = ar->panels.first; pa; pa = pa_next) {
			pa_next = pa->next;
			if (pa->activedata) {
				MEM_freeN(pa->activedata);
			}
			MEM_freeN(pa);
		}
	}

	for (uilst = ar->ui_lists.first; uilst; uilst = uilst->next) {
		if (uilst->dyn_data) {
			uiListDyn *dyn_data = uilst->dyn_data;
			if (dyn_data->items_filter_flags) {
				MEM_freeN(dyn_data->items_filter_flags);
			}
			if (dyn_data->items_filter_neworder) {
				MEM_freeN(dyn_data->items_filter_neworder);
			}
			MEM_freeN(dyn_data);
		}
		if (uilst->properties) {
			IDP_FreeProperty(uilst->properties);
			MEM_freeN(uilst->properties);
		}
	}
	BLI_freelistN(&ar->ui_lists);
	BLI_freelistN(&ar->ui_previews);
	BLI_freelistN(&ar->panels_category);
	BLI_freelistN(&ar->panels_category_active);
}
Ejemplo n.º 16
0
void bone_free(bArmature *arm, EditBone *bone)
{
	if (arm->act_edbone == bone)
		arm->act_edbone = NULL;

	if (bone->prop) {
		IDP_FreeProperty(bone->prop);
		MEM_freeN(bone->prop);
	}

	BLI_freelinkN(arm->edbo, bone);
}
Ejemplo n.º 17
0
void BKE_userdef_free(void)
{
	wmKeyMap *km;
	wmKeyMapItem *kmi;
	wmKeyMapDiffItem *kmdi;
	bAddon *addon, *addon_next;
	uiFont *font;

	for (km = U.user_keymaps.first; km; km = km->next) {
		for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
			if (kmdi->add_item) {
				keymap_item_free(kmdi->add_item);
				MEM_freeN(kmdi->add_item);
			}
			if (kmdi->remove_item) {
				keymap_item_free(kmdi->remove_item);
				MEM_freeN(kmdi->remove_item);
			}
		}

		for (kmi = km->items.first; kmi; kmi = kmi->next)
			keymap_item_free(kmi);

		BLI_freelistN(&km->diff_items);
		BLI_freelistN(&km->items);
	}
	
	for (addon = U.addons.first; addon; addon = addon_next) {
		addon_next = addon->next;
		if (addon->prop) {
			IDP_FreeProperty(addon->prop);
			MEM_freeN(addon->prop);
		}
		MEM_freeN(addon);
	}

	for (font = U.uifonts.first; font; font = font->next) {
		BLF_unload_id(font->blf_id);
	}

	BLF_default_set(-1);

	BLI_freelistN(&U.autoexec_paths);

	BLI_freelistN(&U.uistyles);
	BLI_freelistN(&U.uifonts);
	BLI_freelistN(&U.themes);
	BLI_freelistN(&U.user_keymaps);
}
Ejemplo n.º 18
0
void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_)
{
	struct IDProperty *prop = (struct IDProperty *) prop_;
	IDProperty *group;
	
	if (!rd->ffcodecdata.properties) {
		return;
	}

	group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type);
	if (group && prop) {
		IDP_RemFromGroup(group, prop);
		IDP_FreeProperty(prop);
		MEM_freeN(prop);
	}
}
Ejemplo n.º 19
0
/**
 * Copy the internal members of each pose channel including constraints
 * and ID-Props, used when duplicating bones in editmode.
 * (unlike copy_pose_channel_data which only does posing-related stuff).
 *
 * \note use when copying bones in editmode (on returned value from #BKE_pose_channel_verify)
 */
void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from)
{
	/* copy transform locks */
	pchan->protectflag = pchan_from->protectflag;

	/* copy rotation mode */
	pchan->rotmode = pchan_from->rotmode;

	/* copy bone group */
	pchan->agrp_index = pchan_from->agrp_index;

	/* ik (dof) settings */
	pchan->ikflag = pchan_from->ikflag;
	copy_v3_v3(pchan->limitmin, pchan_from->limitmin);
	copy_v3_v3(pchan->limitmax, pchan_from->limitmax);
	copy_v3_v3(pchan->stiffness, pchan_from->stiffness);
	pchan->ikstretch = pchan_from->ikstretch;
	pchan->ikrotweight = pchan_from->ikrotweight;
	pchan->iklinweight = pchan_from->iklinweight;
	
	/* bbone settings (typically not animated) */
	pchan->bboneflag = pchan_from->bboneflag;
	pchan->bbone_next = pchan_from->bbone_next;
	pchan->bbone_prev = pchan_from->bbone_prev;

	/* constraints */
	BKE_constraints_copy(&pchan->constraints, &pchan_from->constraints, true);

	/* id-properties */
	if (pchan->prop) {
		/* unlikely but possible it exists */
		IDP_FreeProperty(pchan->prop);
		MEM_freeN(pchan->prop);
		pchan->prop = NULL;
	}
	if (pchan_from->prop) {
		pchan->prop = IDP_CopyProperty(pchan_from->prop);
	}

	/* custom shape */
	pchan->custom = pchan_from->custom;
	if (pchan->custom) {
		id_us_plus(&pchan->custom->id);
	}

	pchan->custom_scale = pchan_from->custom_scale;
}
Ejemplo n.º 20
0
static void node_free_script(bNode *node)
{
    NodeShaderScript *nss = node->storage;

    if (nss) {
        if (nss->bytecode) {
            MEM_freeN(nss->bytecode);
        }

        if (nss->prop) {
            IDP_FreeProperty(nss->prop);
            MEM_freeN(nss->prop);
        }

        MEM_freeN(nss);
    }
}
Ejemplo n.º 21
0
void ED_armature_ebone_listbase_free(ListBase *lb)
{
	EditBone *ebone, *ebone_next;

	for (ebone = lb->first; ebone; ebone = ebone_next) {
		ebone_next = ebone->next;

		if (ebone->prop) {
			IDP_FreeProperty(ebone->prop);
			MEM_freeN(ebone->prop);
		}

		MEM_freeN(ebone);
	}

	BLI_listbase_clear(lb);
}
Ejemplo n.º 22
0
/* Free list of backups, including any side data it may use */
static void poselib_backup_free_data (tPoseLib_PreviewData *pld)
{
	tPoseLib_Backup *plb, *plbn;
	
	for (plb= pld->backups.first; plb; plb= plbn) {
		plbn= plb->next;
		
		/* free custom data */
		if (plb->oldprops) {
			IDP_FreeProperty(plb->oldprops);
			MEM_freeN(plb->oldprops);
		}
		
		/* free backup element now */
		BLI_freelinkN(&pld->backups, plb);
	}
}
Ejemplo n.º 23
0
void BKE_pose_channel_free(bPoseChannel *pchan)
{
	if (pchan->custom) {
		id_us_min(&pchan->custom->id);
		pchan->custom = NULL;
	}

	if (pchan->mpath) {
		animviz_free_motionpath(pchan->mpath);
		pchan->mpath = NULL;
	}

	BKE_free_constraints(&pchan->constraints);
	
	if (pchan->prop) {
		IDP_FreeProperty(pchan->prop);
		MEM_freeN(pchan->prop);
	}
}
Ejemplo n.º 24
0
void free_pose_channel(bPoseChannel *pchan)
{
	// XXX this case here will need to be removed when the new motionpaths are ready
	if (pchan->path) {
		MEM_freeN(pchan->path);
		pchan->path= NULL;
	}
	
	if (pchan->mpath) {
		animviz_free_motionpath(pchan->mpath);
		pchan->mpath= NULL;
	}
	
	free_constraints(&pchan->constraints);
	
	if (pchan->prop) {
		IDP_FreeProperty(pchan->prop);
		MEM_freeN(pchan->prop);
	}
}
Ejemplo n.º 25
0
void ED_armature_edit_free(struct bArmature *arm)
{
	EditBone *eBone;
	
	/*	Clear the editbones list */
	if (arm->edbo) {
		if (arm->edbo->first) {
			for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
				if (eBone->prop) {
					IDP_FreeProperty(eBone->prop);
					MEM_freeN(eBone->prop);
				}
			}
			
			BLI_freelistN(arm->edbo);
		}
		MEM_freeN(arm->edbo);
		arm->edbo = NULL;
		arm->act_edbone = NULL;
	}
}
Ejemplo n.º 26
0
/**
 * Deallocates a pose channel.
 * Does not free the pose channel itself.
 */
void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
{
	if (pchan->custom) {
		if (do_id_user) {
			id_us_min(&pchan->custom->id);
		}
		pchan->custom = NULL;
	}

	if (pchan->mpath) {
		animviz_free_motionpath(pchan->mpath);
		pchan->mpath = NULL;
	}

	BKE_constraints_free_ex(&pchan->constraints, do_id_user);
	
	if (pchan->prop) {
		IDP_FreeProperty(pchan->prop);
		MEM_freeN(pchan->prop);
	}
}
Ejemplo n.º 27
0
/**
 * Free (or release) any data used by this ViewLayer.
 */
void BKE_view_layer_free_ex(ViewLayer *view_layer, const bool do_id_user)
{
  view_layer->basact = NULL;

  BLI_freelistN(&view_layer->object_bases);

  if (view_layer->object_bases_hash) {
    BLI_ghash_free(view_layer->object_bases_hash, NULL, NULL);
  }

  for (LayerCollection *lc = view_layer->layer_collections.first; lc; lc = lc->next) {
    layer_collection_free(view_layer, lc);
  }
  BLI_freelistN(&view_layer->layer_collections);

  for (ViewLayerEngineData *sled = view_layer->drawdata.first; sled; sled = sled->next) {
    if (sled->storage) {
      if (sled->free) {
        sled->free(sled->storage);
      }
      MEM_freeN(sled->storage);
    }
  }
  BLI_freelistN(&view_layer->drawdata);

  MEM_SAFE_FREE(view_layer->stats);

  BKE_freestyle_config_free(&view_layer->freestyle_config, do_id_user);

  if (view_layer->id_properties) {
    IDP_FreeProperty(view_layer->id_properties);
  }

  MEM_SAFE_FREE(view_layer->object_bases_array);

  MEM_freeN(view_layer);
}
Ejemplo n.º 28
0
/**
 * \note group can be a pointer array or a group.
 * assume we already checked key is a string.
 *
 * \return success.
 */
bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, PyObject *ob)
{
	IDProperty *prop = idp_from_PyObject(name_obj, ob);
	if (prop == NULL) {
		return false;
	}

	if (group->type == IDP_IDPARRAY) {
		IDP_AppendArray(group, prop);
		/* IDP_AppendArray does a shallow copy (memcpy), only free memory */
		MEM_freeN(prop);
	}
	else {
		IDProperty *prop_exist;

		/* avoid freeing when types match in case they are referenced by the UI, see: T37073
		 * obviously this isn't a complete solution, but helps for common cases. */
		prop_exist = IDP_GetPropertyFromGroup(group, prop->name);
		if ((prop_exist != NULL) &&
		    (prop_exist->type == prop->type) &&
		    (prop_exist->subtype == prop->subtype))
		{
			/* Preserve prev/next links!!! See T42593. */
			prop->prev = prop_exist->prev;
			prop->next = prop_exist->next;

			IDP_FreeProperty(prop_exist);
			*prop_exist = *prop;
			MEM_freeN(prop);
		}
		else {
			IDP_ReplaceInGroup_ex(group, prop, prop_exist);
		}
	}

	return true;
}
Ejemplo n.º 29
0
/* makes copies of internal data, unlike copy_pose_channel_data which only
 * copies the pose state.
 * hint: use when copying bones in editmode (on returned value from verify_pose_channel) */
void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_from)
{
	/* copy transform locks */
	pchan->protectflag = pchan_from->protectflag;

	/* copy rotation mode */
	pchan->rotmode = pchan_from->rotmode;

	/* copy bone group */
	pchan->agrp_index= pchan_from->agrp_index;

	/* ik (dof) settings */
	pchan->ikflag = pchan_from->ikflag;
	VECCOPY(pchan->limitmin, pchan_from->limitmin);
	VECCOPY(pchan->limitmax, pchan_from->limitmax);
	VECCOPY(pchan->stiffness, pchan_from->stiffness);
	pchan->ikstretch= pchan_from->ikstretch;
	pchan->ikrotweight= pchan_from->ikrotweight;
	pchan->iklinweight= pchan_from->iklinweight;

	/* constraints */
	copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE);

	/* id-properties */
	if(pchan->prop) {
		/* unlikely but possible it exists */
		IDP_FreeProperty(pchan->prop);
		MEM_freeN(pchan->prop);
		pchan->prop= NULL;
	}
	if(pchan_from->prop) {
		pchan->prop= IDP_CopyProperty(pchan_from->prop);
	}

	/* custom shape */
	pchan->custom= pchan_from->custom;
}
Ejemplo n.º 30
0
Archivo: wm.c Proyecto: mik0001/Blender
void WM_operator_free(wmOperator *op)
{

#ifdef WITH_PYTHON
	if(op->py_instance) {
		/* do this first incase there are any __del__ functions or
		 * similar that use properties */
		BPY_DECREF(op->py_instance);
	}
#endif

	if(op->ptr) {
		op->properties= op->ptr->data;
		MEM_freeN(op->ptr);
	}

	if(op->properties) {
		IDP_FreeProperty(op->properties);
		MEM_freeN(op->properties);
	}

	if(op->reports && (op->reports->flag & RPT_FREE)) {
		BKE_reports_clear(op->reports);
		MEM_freeN(op->reports);
	}

	if(op->macro.first) {
		wmOperator *opm, *opmnext;
		for(opm= op->macro.first; opm; opm= opmnext) {
			opmnext = opm->next;
			WM_operator_free(opm);
		}
	}
	
	MEM_freeN(op);
}