[Bf-blender-cvs] [d8169c2] asset-experiments: FileBrowser - fix two crashers.
Bastien Montagne
noreply at git.blender.org
Thu Apr 2 13:53:53 CEST 2015
Commit: d8169c2db7f4c4c8a6d7d09de8bc64ce1e8bb7e5
Author: Bastien Montagne
Date: Thu Apr 2 13:51:13 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rBd8169c2db7f4c4c8a6d7d09de8bc64ce1e8bb7e5
FileBrowser - fix two crashers.
* Full path is no more static, so we need dynamic tooltips to use it (still an
issue with drag stuff here :| ).
* Remove timer would attempt to free timer's customdata, which is mere int-in-pointer
in case of new notifier timer, so we need a special tweak on remove here.
===================================================================
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/space_file.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_window.c
===================================================================
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index f7b556c..294b72d 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -73,6 +73,13 @@
#include "file_intern.h" // own include
+/* Dummy helper - we need dynamic tooltips here. */
+static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
+{
+ char *dyn_tooltip = argN;
+ return BLI_strdup(dyn_tooltip);
+}
+
/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d.
* The controls are laid out as follows:
*
@@ -250,10 +257,11 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon,
/*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/
- but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, path);
+ but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL);
+ UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path));
if (drag) {
- UI_but_drag_set_path(but, path);
+ UI_but_drag_set_path(but, "" /* path */); /* XXX TODO FIXME broken, dragpath expects a static string too... :( */
}
}
@@ -352,10 +360,12 @@ static void file_draw_preview(uiBlock *block, const char *path,
fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
}
- but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, path);
+ but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, NULL);
+ UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path));
+
/* dragregion */
if (drag) {
- UI_but_drag_set_image(but, path, icon, imb, scale);
+ UI_but_drag_set_image(but, "" /* path */, icon, imb, scale); /* XXX TODO FIXME broken, dragpath expects a static string too... :( */
}
glDisable(GL_BLEND);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index cb3e2cf..41f5a5b 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -173,7 +173,7 @@ static void file_exit(wmWindowManager *wm, ScrArea *sa)
SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
if (sfile->previews_timer) {
- WM_event_remove_timer(wm, NULL, sfile->previews_timer);
+ WM_event_remove_timer_notifier(wm, NULL, sfile->previews_timer);
sfile->previews_timer = NULL;
}
@@ -263,7 +263,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
else {
filelist_cache_previews_set(sfile->files, false);
if (sfile->previews_timer) {
- WM_event_remove_timer(wm, CTX_wm_window(C), sfile->previews_timer);
+ WM_event_remove_timer_notifier(wm, CTX_wm_window(C), sfile->previews_timer);
sfile->previews_timer = NULL;
}
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 938e052..3460b29 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -187,6 +187,7 @@ void wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep);
struct wmTimer *WM_event_add_timer_notifier(struct wmWindowManager *wm, struct wmWindow *win, unsigned int type, double timestep);
void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer);
+void WM_event_remove_timer_notifier(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer);
void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, bool do_sleep);
/* operator api, default callbacks */
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 67cc09a..326d3be 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1297,6 +1297,12 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
}
}
+void WM_event_remove_timer_notifier(wmWindowManager *wm, wmWindow *win, wmTimer *timer)
+{
+ timer->customdata = NULL;
+ WM_event_remove_timer(wm, win, timer);
+}
+
/* ******************* clipboard **************** */
static char *wm_clipboard_text_get_ex(bool selection, int *r_len,
More information about the Bf-blender-cvs
mailing list