Commit: fb3528d088709e8221496efaa57522b1406f4ca8
Author: Campbell Barton
Date:   Sun Apr 15 10:34:41 2018 +0200
Branches: master
https://developer.blender.org/rBfb3528d088709e8221496efaa57522b1406f4ca8

Fix T54593: Py text edits crash (undo regression)

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

M       source/blender/blenkernel/intern/text.c

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

diff --git a/source/blender/blenkernel/intern/text.c 
b/source/blender/blenkernel/intern/text.c
index c7588a4ed48..212a9c86613 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -526,29 +526,26 @@ void BKE_text_make_local(Main *bmain, Text *text, const 
bool lib_local)
 
 void BKE_text_clear(Text *text, TextUndoBuf *utxt) /* called directly from rna 
*/
 {
-       int oldstate;
-
-       if (utxt) {
-               oldstate = txt_get_undostate();
-       }
-       txt_set_undostate(utxt != NULL);
+       const bool undostate_orig = txt_get_undostate();
+       txt_set_undostate(utxt == NULL);
 
        txt_sel_all(text);
        txt_delete_sel(text, utxt);
 
-       txt_set_undostate(oldstate);
+       txt_set_undostate(undostate_orig);
 
        txt_make_dirty(text);
 }
 
 void BKE_text_write(Text *text, TextUndoBuf *utxt, const char *str) /* called 
directly from rna */
 {
-       int oldstate;
+       const bool undostate_orig = txt_get_undostate();
+       txt_set_undostate(utxt == NULL);
 
-       oldstate = txt_get_undostate();
        txt_insert_buf(text, utxt, str);
        txt_move_eof(text, 0);
-       txt_set_undostate(oldstate);
+
+       txt_set_undostate(undostate_orig);
 
        txt_make_dirty(text);
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to