[Bf-blender-cvs] [02e0c6f42e7] master: Fix T90430: Crash when dragging material

Julian Eisel noreply at git.blender.org
Thu Aug 5 12:14:19 CEST 2021


Commit: 02e0c6f42e76e2cd5d086bde336789991434eba5
Author: Julian Eisel
Date:   Thu Aug 5 12:10:49 2021 +0200
Branches: master
https://developer.blender.org/rB02e0c6f42e76e2cd5d086bde336789991434eba5

Fix T90430: Crash when dragging material

Was trying to get asset information even when there was none, i.e. when
the material wasn't an asset or not dragged from the Asset Browser.

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

M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_dragdrop.c

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

diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 0803b4c4776..72d0c11e192 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -534,8 +534,8 @@ static char *view3d_mat_drop_tooltip(bContext *C,
                                      const wmEvent *event,
                                      struct wmDropBox *drop)
 {
-  wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, ID_MA);
-  RNA_string_set(drop->ptr, "name", asset_drag->name);
+  const char *name = WM_drag_get_item_name(drag);
+  RNA_string_set(drop->ptr, "name", name);
   return ED_object_ot_drop_named_material_tooltip(C, drop->ptr, event);
 }
 
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index fb973592a57..8c1511fd152 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -728,6 +728,8 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain,
                                    struct wmDrag *drag,
                                    struct wmDropBox *drop);
 
+const char *WM_drag_get_item_name(struct wmDrag *drag);
+
 /* Set OpenGL viewport and scissor */
 void wmViewport(const struct rcti *winrct);
 void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct);
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index dcbb502117e..76bb93b681c 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -469,7 +469,7 @@ static void wm_drop_operator_draw(const char *name, int x, int y)
   UI_fontstyle_draw_simple_backdrop(fstyle, x, y, name, col_fg, col_bg);
 }
 
-static const char *wm_drag_name(wmDrag *drag)
+const char *WM_drag_get_item_name(wmDrag *drag)
 {
   switch (drag->type) {
     case WM_DRAG_ID: {
@@ -583,11 +583,11 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
     }
 
     if (rect) {
-      int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag));
+      int w = UI_fontstyle_string_width(fstyle, WM_drag_get_item_name(drag));
       drag_rect_minmax(rect, x, y, x + w, y + iconsize);
     }
     else {
-      UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), text_col);
+      UI_fontstyle_draw_simple(fstyle, x, y, WM_drag_get_item_name(drag), text_col);
     }
 
     /* operator name with roundbox */
@@ -614,7 +614,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
       }
 
       if (rect) {
-        int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag));
+        int w = UI_fontstyle_string_width(fstyle, WM_drag_get_item_name(drag));
         drag_rect_minmax(rect, x, y, x + w, y + iconsize);
       }
       else {



More information about the Bf-blender-cvs mailing list