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;
cxFree(a, note->title);
note->title = cx_strdup_a(a, cx_str(title)).ptr;
+ cxFree(a, note->name);
+ note->name = cx_strdup_a(a, cx_str(title)).ptr;
+
cxFree(a, note->content.ptr);
note->content = cx_strdup_a(a, cx_str(content));
+ if(strlen(title) == 0) {
+ printf("break\n");
+ }
+
if(note->note_id == 0) {
// new note
note_store_new_note_async(obj, note, NULL, NULL);
void notebookmodel_detach(NotebookModel *model) {
if(model->current_note && model->current_note->model->modified) {
+ //notebookmodel_detach_current_note(model);
note_save(model->window->obj, model, model->current_note);
}
notemodel_set_note(notemodel, note);
}
- notebookmodel_detach_current_note(model);
+ if(model->current_note == note) {
+ // workaround, see top comment
+ ui_detach_document2(model->ctx, model->current_note->model);
+ model->current_note = NULL;
+ } else{
+ notebookmodel_detach_current_note(model);
+ }
+
ui_attach_document(model->ctx, note->model);
// TODO: this is only a workaround and should be removed when
// sub-document groups are supported