Fix: Possibly incorrect return value in VSE text editing operators

Paste and text insert could delete selected text, but then cancel
operator execution due to buffer being too small. Ensure, that operator
returns value based on state being actually changed or not.

Pull Request: https://projects.blender.org/blender/blender/pulls/133569
This commit is contained in:
Richard Antalik 2025-01-26 01:35:48 +01:00 • committed by Richard Antalik
parent 974ac39044
commit bf732e4237

View file

@ -385,13 +385,15 @@ void SEQUENCER_OT_text_cursor_move(wmOperatorType *ot)
static bool text_insert(TextVars *data, const char *buf)
{
const TextVarsRuntime *text = data->runtime;
const bool selection_was_deleted = text_has_selection(data);
delete_selected_text(data);
const size_t in_str_len = BLI_strnlen(buf, sizeof(buf));
const size_t text_str_len = BLI_strnlen(data->text, sizeof(data->text));
if (text_str_len + in_str_len + 1 > sizeof(data->text)) {
return false;
return selection_was_deleted;
}
const seq::CharInfo cur_char = character_at_cursor_offset_get(text, data->cursor_offset);
@ -810,7 +812,6 @@ static int sequencer_text_edit_paste_exec(bContext *C, wmOperator * /*op*/)
const Strip *strip = SEQ_select_active_get(CTX_data_scene(C));
TextVars *data = static_cast<TextVars *>(strip->effectdata);
const TextVarsRuntime *text = data->runtime;
delete_selected_text(data);
int clipboard_len;
char *clipboard_buf = WM_clipboard_text_get(false, true, &clipboard_len);
@ -819,6 +820,7 @@ static int sequencer_text_edit_paste_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_CANCELLED;
}
delete_selected_text(data);
const int max_str_len = sizeof(data->text) - (BLI_strnlen(data->text, sizeof(data->text)) + 1);
/* Maximum bytes that can be filled into `data->text`. */