UI: show error when pasting fails
This commit is contained in:
parent
3e0f117ef5
commit
bc3db85da8
|
@ -2218,6 +2218,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
|||
int buf_paste_len = 0;
|
||||
const char *buf_paste = "";
|
||||
bool buf_paste_alloc = false;
|
||||
bool show_report = false; /* use to display errors parsing paste input */
|
||||
|
||||
if (mode == 'v' && but->lock == true) {
|
||||
return;
|
||||
|
@ -2268,6 +2269,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
|||
ui_but_string_set(C, but, buf_paste);
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
else {
|
||||
/* evaluating will report errors */
|
||||
show_report = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2294,6 +2299,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
|||
ui_but_v3_set(but, xyz);
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
else {
|
||||
WM_report(C, RPT_ERROR, "Paste expected 3 numbers, formatted: '[n, n, n]'");
|
||||
show_report = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2335,6 +2344,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
|||
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
else {
|
||||
WM_report(C, RPT_ERROR, "Paste expected 4 numbers, formatted: '[n, n, n, n]'");
|
||||
show_report = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2429,6 +2442,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
|||
if (buf_paste_alloc) {
|
||||
MEM_freeN((void *)buf_paste);
|
||||
}
|
||||
|
||||
if (show_report) {
|
||||
WM_report_banner_show(C);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue