From 358b7a97c2fcaa4f23f59cc19d3316cd0908f466 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 4 Mar 2025 15:03:09 +0100 Subject: [PATCH] fix wrong order in notebookmodel_detach, note_save must be called before detaching the model --- application/note.c | 3 +++ application/notebook.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/application/note.c b/application/note.c index 84a613a..09a9053 100644 --- a/application/note.c +++ b/application/note.c @@ -76,7 +76,10 @@ void note_load_content(UiObject *obj, NotebookModel *notebook, Note *note) { void note_save(UiObject *obj, NotebookModel *notebook, Note *note) { NoteModel *m = note->model; + printf("title obj: %s\n", m->title->obj); + char *title = ui_get(m->title); + printf("title: %s\n", title); char *content = ui_get(m->text); const CxAllocator *a = notebook->current_notes_pool->allocator; diff --git a/application/notebook.c b/application/notebook.c index 895498a..8156d0b 100644 --- a/application/notebook.c +++ b/application/notebook.c @@ -75,14 +75,14 @@ void notebookmodel_attach(MainWindow *window, NotebookModel *model) { } void notebookmodel_detach(NotebookModel *model) { + if(model->current_note && model->current_note->model->modified) { + note_save(model->window->obj, model, model->current_note); + } + if(model->window) { ui_detach_document2(model->window->obj->ctx, model); model->window->current_notebook = NULL; } - - if(model->current_note && model->current_note->model->modified) { - note_save(model->window->obj, model, model->current_note); - } } void notebookmodel_set_collection(NotebookModel *model, Collection *collection) { -- 2.43.5