From 850000492cd43e40109b3a11c8613b5fff577755 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 3 May 2025 11:33:01 +0300 Subject: fixed teco_doc_undo_exchange(): use reference counting now * When popping from the Q-Register stack to local Q-Registers in macro calls, problems would arise when rubbing out that macro call since we would eventually restore a pointer that has been permanently freed along with the local Q-Registers. * Naturally this could result in everything from Valgrind warnings to crashes. * Added test case. * There is still a test case that fails when run under `--valgrind`, but it's apparently due to a glib-internal memory leak. --- src/doc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/doc.h') diff --git a/src/doc.h b/src/doc.h index 4ecfd21..99568ff 100644 --- a/src/doc.h +++ b/src/doc.h @@ -33,6 +33,8 @@ */ typedef struct teco_doc_scintilla_t teco_doc_scintilla_t; +TECO_DECLARE_UNDO_OBJECT(doc_scintilla, teco_doc_scintilla_t *); + /** * A Scintilla document. * @@ -108,7 +110,7 @@ void teco_doc_exchange(teco_doc_t *ctx, teco_doc_t *other); static inline void teco_doc_undo_exchange(teco_doc_t *ctx) { - teco_undo_ptr(ctx->doc); + teco_undo_object_doc_scintilla_push(&ctx->doc); teco_doc_undo_reset(ctx); } -- cgit v1.2.3