From b09a857ad67a2092dbeacfb3030b1447ce067ac2 Mon Sep 17 00:00:00 2001 From: Shen Wei Date: Wed, 4 Dec 2024 15:20:39 +0800 Subject: [PATCH 1/4] clear copy always to avoid stack overflow --- src/Edit/Interface/edit_interface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Edit/Interface/edit_interface.cpp b/src/Edit/Interface/edit_interface.cpp index 06a960032..ea387bced 100644 --- a/src/Edit/Interface/edit_interface.cpp +++ b/src/Edit/Interface/edit_interface.cpp @@ -828,6 +828,7 @@ edit_interface_rep::apply_changes () { if (tremble_count > 3) dw= (1 + min (tremble_count - 3, 25)) * 2 * pixel; SI /*P1= zpixel,*/ P2= 2 * zpixel, P3= 3 * zpixel; cursor cu= get_cursor (); + copy_always= rectangles (); rectangle ocr (oc->ox + ((SI) ((oc->y1 - dw) * oc->slope)) - P3 - dw, oc->oy + (oc->y1 - dw) - P3, oc->ox + ((SI) ((oc->y2 + dw) * oc->slope)) + P2 + dw, From df842c503c1da8d86542f7fb440f98c4729835c3 Mon Sep 17 00:00:00 2001 From: Shen Wei Date: Wed, 4 Dec 2024 17:23:13 +0800 Subject: [PATCH 2/4] clang-format --- src/Edit/Interface/edit_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Edit/Interface/edit_interface.cpp b/src/Edit/Interface/edit_interface.cpp index ea387bced..71062aa85 100644 --- a/src/Edit/Interface/edit_interface.cpp +++ b/src/Edit/Interface/edit_interface.cpp @@ -828,7 +828,7 @@ edit_interface_rep::apply_changes () { if (tremble_count > 3) dw= (1 + min (tremble_count - 3, 25)) * 2 * pixel; SI /*P1= zpixel,*/ P2= 2 * zpixel, P3= 3 * zpixel; cursor cu= get_cursor (); - copy_always= rectangles (); + copy_always = rectangles (); rectangle ocr (oc->ox + ((SI) ((oc->y1 - dw) * oc->slope)) - P3 - dw, oc->oy + (oc->y1 - dw) - P3, oc->ox + ((SI) ((oc->y2 + dw) * oc->slope)) + P2 + dw, From e0349fab12758da124e775682018cd573a19ac30 Mon Sep 17 00:00:00 2001 From: Shen Wei Date: Mon, 9 Dec 2024 15:03:57 +0800 Subject: [PATCH 3/4] trigger ci From a1e343c00fd7c9ad470addd58793a7f4f8c3251f Mon Sep 17 00:00:00 2001 From: Shen Wei Date: Sat, 21 Dec 2024 16:16:24 +0800 Subject: [PATCH 4/4] a more safer way to update copy_always, do not add duplicated rectangles on the top instead of clearing it --- src/Edit/Interface/edit_interface.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Edit/Interface/edit_interface.cpp b/src/Edit/Interface/edit_interface.cpp index 71062aa85..3e2b2f2aa 100644 --- a/src/Edit/Interface/edit_interface.cpp +++ b/src/Edit/Interface/edit_interface.cpp @@ -828,20 +828,23 @@ edit_interface_rep::apply_changes () { if (tremble_count > 3) dw= (1 + min (tremble_count - 3, 25)) * 2 * pixel; SI /*P1= zpixel,*/ P2= 2 * zpixel, P3= 3 * zpixel; cursor cu= get_cursor (); - copy_always = rectangles (); rectangle ocr (oc->ox + ((SI) ((oc->y1 - dw) * oc->slope)) - P3 - dw, oc->oy + (oc->y1 - dw) - P3, oc->ox + ((SI) ((oc->y2 + dw) * oc->slope)) + P2 + dw, oc->oy + (oc->y2 + dw) + P3); - copy_always= rectangles (ocr, copy_always); + if (is_nil (copy_always) || copy_always->item != ocr) { + copy_always= rectangles (ocr, copy_always); + } invalidate (ocr->x1, ocr->y1, ocr->x2, ocr->y2); rectangle ncr (cu->ox + ((SI) ((cu->y1 - dw) * cu->slope)) - P3 - dw, cu->oy + (cu->y1 - dw) - P3, cu->ox + ((SI) ((cu->y2 + dw) * cu->slope)) + P2 + dw, cu->oy + (cu->y2 + dw) + P3); invalidate (ncr->x1, ncr->y1, ncr->x2, ncr->y2); - copy_always= rectangles (ncr, copy_always); - oc = copy (cu); + if (is_nil (copy_always) || copy_always->item != ncr) { + copy_always= rectangles (ncr, copy_always); + } + oc= copy (cu); // set hot spot in the gui send_cursor (this, (SI) floor (cu->ox * magf), (SI) floor (cu->oy * magf));