From: Olaf Wintermann Date: Sun, 20 Apr 2025 12:37:33 +0000 (+0200) Subject: fix EmbeddedWidget markdown serialization X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=6f5cd3a84dd02d95cfac30341f584fd5351eb8a9;p=note.git fix EmbeddedWidget markdown serialization --- diff --git a/application/gtk-text.c b/application/gtk-text.c index 56fef7c..2056180 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -738,9 +738,7 @@ void editor_apply_styles(Resource *note, UIWIDGET textview, UiText *text, CxList cx_foreach(MDDocStyleSection*, sec, i) { if(sec->length == MDDocStyleSection_IMAGE) { Attachment *attachment = note_get_attachment(note, sec->link); - if(attachment && attachment->ui->img->value) { - GdkPixbuf *pixbuf = attachment->ui->img->value; - + if(attachment && attachment->ui->img->value) { GtkTextIter iter; gtk_text_buffer_get_iter_at_offset(buffer, &iter, sec->pos); editor_insert_image(editor, attachment, &iter); @@ -829,6 +827,7 @@ cxmutstr editor_get_markdown(UiText *text, const CxAllocator *a) { CxMap *prev_tags = cxHashMapCreateSimple(CX_STORE_POINTERS); GtkTextChildAnchor *anchor = NULL; + GtkTextChildAnchor *prevAnchor = NULL; GtkTextIter end_iter; gtk_text_buffer_get_iter_at_offset(buffer, &end_iter, -1); @@ -843,11 +842,14 @@ cxmutstr editor_get_markdown(UiText *text, const CxAllocator *a) { iter = end_iter; } - if(anchor) { + // the same anchor is returned at 2 iter positions, so we need to + // check if this anchor was already serialized + if(anchor && anchor != prevAnchor) { EmbeddedWidget *em = g_object_get_data(G_OBJECT(anchor), "em"); if(em) { em->serialize(em, &out); } + prevAnchor = anchor; anchor = NULL; }