]> uap-core.de Git - note.git/commitdiff
switching notebooks will save the current note
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 25 Oct 2025 18:54:23 +0000 (20:54 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 25 Oct 2025 18:54:23 +0000 (20:54 +0200)
application/notebook.c

index e3e45ecbe28530cfe06e91412638d2a12f192b20..2b08f422666e2657e2079320d6d1f06c2d331a17 100644 (file)
@@ -78,20 +78,18 @@ void notebookmodel_attach(MainWindow *window, NotebookModel *model) {
 }
 
 void notebookmodel_detach(NotebookModel *model) {
-    // TODO: workaround for a toolkit bug, that reattaching a document
-    // that has sub-documents will not update all bindings
     if(model->current_note) {
-        //int i = ui_get(model->current_note->model->type);
-        //printf("type: %d\n", i);
+        // TODO: model->modified doesnt work yet, remove || 1 when it works
+        if(model->current_note->model->modified ||  1) {
+            note_save(model->window->obj, model, model->current_note);
+        }
+        
+        // TODO: workaround for a toolkit bug, that reattaching a document
+        // with sub-documents will not update all bindings
         ui_detach_document(model->ctx, model->current_note->model);
         model->current_note = NULL;
     }
     
-    if(model->current_note && model->current_note->model->modified) {
-        //notebookmodel_detach_current_note(model);
-        note_save(model->window->obj, model, model->current_note);
-    }
-    
     if(model->window) {
         ui_detach_document(model->window->obj->ctx, model);
         model->window->current_notebook = NULL;