Fix T56947: Copy text from disabled search menu crashed
authorJacques Lucke <mail@jlucke.com>
Fri, 28 Sep 2018 12:12:00 +0000 (14:12 +0200)
committerJacques Lucke <mail@jlucke.com>
Fri, 28 Sep 2018 12:12:25 +0000 (14:12 +0200)
Reviewers: brecht

Differential Revision: https://developer.blender.org/D3745

source/blender/editors/interface/interface_handlers.c

index bff43e5cbaa13c8f28a706fa3cc14fb057830ee7..c08384c3ef01b6b5b4ee7a30459fdac6ae52078f 100644 (file)
@@ -2224,12 +2224,9 @@ static void ui_but_paste_color(bContext *C, uiBut *but, char *buf_paste)
        }
 }
 
-static void ui_but_copy_text(bContext *C, uiBut *but, char *output, int max_output_len)
+static void ui_but_copy_text(uiBut *but, char *output, int max_output_len)
 {
-       button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
-       strncpy(output, but->active->str, max_output_len);
-       but->active->cancel = true;
-       button_activate_state(C, but, BUTTON_STATE_EXIT);
+       ui_but_string_get(but, output, max_output_len);
 }
 
 static void ui_but_paste_text(bContext *C, uiBut *but, uiHandleButtonData *data, char *buf_paste)
@@ -2342,7 +2339,7 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
        case UI_BTYPE_TEXT:
        case UI_BTYPE_SEARCH_MENU:
                if (!has_required_data) break;
-               ui_but_copy_text(C, but, buffer_to_copy, max_copy_length);
+               ui_but_copy_text(but, buffer_to_copy, max_copy_length);
                break;
 
        case UI_BTYPE_COLORBAND: