Revert to master - those changes are globally valid, but remain incomplete,
[blender.git] / source / blender / blenkernel / intern / brush.c
index 3c7f753e3d82736522f53832fcc94588b50fd33d..e0ffd83080493c33ebf933d103e34b8fcf04ee35 100644 (file)
@@ -197,45 +197,22 @@ Brush *BKE_brush_copy(Brush *brush)
        return brushn;
 }
 
-/**
- * Free (or release) any data used by this brush (does not free the brush itself).
- *
- * \param brush The brush to free.
- * \param do_id_user When \a true, ID datablocks used (referenced) by this brush are 'released'
- *                   (their user count is decreased).
- */
-void BKE_brush_free(Brush *brush, const bool do_id_user)
+/* not brush itself */
+void BKE_brush_free(Brush *brush)
 {
-       if (do_id_user) {
-               if (brush->mtex.tex) {
-                       id_us_min(&brush->mtex.tex->id);
-                       brush->mtex.tex = NULL;
-               }
+       id_us_min((ID *)brush->mtex.tex);
+       id_us_min((ID *)brush->mask_mtex.tex);
+       id_us_min((ID *)brush->paint_curve);
 
-               if (brush->mask_mtex.tex) {
-                       id_us_min(&brush->mask_mtex.tex->id);
-                       brush->mask_mtex.tex = NULL;
-               }
-
-               if (brush->paint_curve) {
-                       id_us_min(&brush->paint_curve->id);
-                       brush->paint_curve = NULL;
-               }
-
-               /* No ID refcount here... */
-               brush->toggle_brush = NULL;
-               brush->clone.image = NULL;
-       }
-
-       if (brush->icon_imbuf) {
+       if (brush->icon_imbuf)
                IMB_freeImBuf(brush->icon_imbuf);
-       }
 
-       curvemapping_free(brush->curve);
+       BKE_previewimg_free(&(brush->preview));
 
-       MEM_SAFE_FREE(brush->gradient);
+       curvemapping_free(brush->curve);
 
-       BKE_previewimg_free(&(brush->preview));
+       if (brush->gradient)
+               MEM_freeN(brush->gradient);
 }
 
 static void extern_local_brush(Brush *brush)