From: Olaf Wintermann Date: Fri, 24 Oct 2025 18:55:22 +0000 (+0200) Subject: fix broken navigation X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=ad905074a088bd72bcddea415182f6427a50c5d3;p=note.git fix broken navigation --- diff --git a/application/notebook.c b/application/notebook.c index ac8a3aa..e3e45ec 100644 --- a/application/notebook.c +++ b/application/notebook.c @@ -190,10 +190,10 @@ void notebookmodel_detach_current_note(NotebookModel *model) { * * If index is not NULL, it is set to the index in the model->notes list */ -Resource* notebookmodel_get_note_by_id(NotebookModel *model, int64_t note_id, size_t *index) { +Note* notebookmodel_get_note_by_id(NotebookModel *model, int64_t note_id, size_t *index) { CxList *list = model->notes->data; // UiList is based on CxList CxIterator i = cxListIterator(list); - cx_foreach(Resource *, note, i) { + cx_foreach(Note *, note, i) { if(note->resource_id == note_id) { if(index) { *index = i.index; diff --git a/application/notebook.h b/application/notebook.h index 3524016..89ea350 100644 --- a/application/notebook.h +++ b/application/notebook.h @@ -49,7 +49,7 @@ void notebookmodel_reload(UiObject *obj, NotebookModel *model); void notebookmodel_attach_note(NotebookModel *model, Note *note); void notebookmodel_detach_current_note(NotebookModel *model); -Resource* notebookmodel_get_note_by_id(NotebookModel *model, int64_t note_id, size_t *index); +Note* notebookmodel_get_note_by_id(NotebookModel *model, int64_t note_id, size_t *index); void notebookmodel_new_note(NotebookModel *model); void notebookmodel_delete_note(NotebookModel *model); diff --git a/application/window.c b/application/window.c index 108fcb9..0b7bac2 100644 --- a/application/window.c +++ b/application/window.c @@ -234,9 +234,8 @@ void* window_notelist_getvalue(void *data, int col) { -NotebookModel* window_get_cached_notebook(MainWindow *window, int64_t collection_id) { - CxHashKey key = cx_hash_key(&collection_id, sizeof(collection_id)); - return cxMapGet(window->notebook_cache, key); +NotebookModel* window_get_cached_notebook(MainWindow *window, int64_t collection_resource_id) { + return cxMapGet(window->notebook_cache, (uint64_t)collection_resource_id); } /* @@ -254,7 +253,7 @@ void window_navigate(MainWindow *window, NavStack *nav) { } size_t note_index; - Resource *note = nav->resource_id != 0 ? notebookmodel_get_note_by_id(notebook, nav->resource_id, ¬e_index) : NULL; + Note *note = nav->resource_id != 0 ? notebookmodel_get_note_by_id(notebook, nav->resource_id, ¬e_index) : NULL; window_notelist_setvisible(window, !(nav->view_flags & VIEW_FLAGS_NO_BROWSER)); @@ -395,14 +394,13 @@ void action_notebook_selected(UiEvent *event, void *userdata) { // reset splitpane visibility window_notelist_setvisible(window, TRUE); - CxHashKey key = cx_hash_key(&collection->resource_id, sizeof(collection->resource_id)); - NotebookModel *notebook = cxMapGet(window->notebook_cache, key); + NotebookModel *notebook = cxMapGet(window->notebook_cache, (uint64_t)collection->resource_id); if(!notebook) { printf("notebook not in cache\n"); notebook = notebookmodel_create(); notebookmodel_set_collection(notebook, collection); notebookmodel_reload(event->obj, notebook); - cxMapPut(window->notebook_cache, key, notebook); + cxMapPut(window->notebook_cache, (uint64_t)collection->resource_id, notebook); } else { printf("notebook in cache\n"); } diff --git a/application/window.h b/application/window.h index b0ea783..998d3b1 100644 --- a/application/window.h +++ b/application/window.h @@ -57,7 +57,7 @@ void window_sidebar_getvalue(UiList *list, void *sublist_userdata, void *rowdata void window_notelist_setvisible(MainWindow *window, UiBool visible); -NotebookModel* window_get_cached_notebook(MainWindow *window, int64_t collection_id); +NotebookModel* window_get_cached_notebook(MainWindow *window, int64_t collection_resource_id); void window_navigate(MainWindow *window, NavStack *nav); diff --git a/ucx/hash_map.c b/ucx/hash_map.c index a7de4e3..85b669c 100644 --- a/ucx/hash_map.c +++ b/ucx/hash_map.c @@ -86,7 +86,7 @@ static void *cx_hash_map_put( struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; const CxAllocator *allocator = map->collection.allocator; - unsigned hash = key.hash; + uint64_t hash = key.hash; if (hash == 0) { cx_hash_murmur(&key); hash = key.hash; @@ -203,7 +203,7 @@ static int cx_hash_map_get_remove( ) { struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; - unsigned hash = key.hash; + uint64_t hash = key.hash; if (hash == 0) { cx_hash_murmur(&key); hash = key.hash;