]> uap-core.de Git - note.git/commitdiff
fix broken navigation
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 24 Oct 2025 18:55:22 +0000 (20:55 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 24 Oct 2025 18:55:22 +0000 (20:55 +0200)
application/notebook.c
application/notebook.h
application/window.c
application/window.h
ucx/hash_map.c

index ac8a3aa7704a6fea7681edda16e6e0126cd9a980..e3e45ecbe28530cfe06e91412638d2a12f192b20 100644 (file)
@@ -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;
index 3524016f2624883b2ccd0cd157df103d202c8c75..89ea350f127135f9eabfebb33fce52a2b502e8e0 100644 (file)
@@ -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);
index 108fcb9947271ef58820cc9ab76c3b9281cbecd5..0b7bac20fe2b5d7e7c4ff503a073c576dfc9ed2d 100644 (file)
@@ -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, &note_index) : NULL;
+    Note *note = nav->resource_id != 0 ? notebookmodel_get_note_by_id(notebook, nav->resource_id, &note_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");
     }
index b0ea783d23ea9aa92903a4ae9e7a1a00c1d830ea..998d3b1cd10cd8f9363706c6f50730745bae0ef5 100644 (file)
@@ -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);
 
index a7de4e37fce64ca1363ab9768b0221dd84b404e5..85b669ce719c058b8122b79fceb44af15bad04fd 100644 (file)
@@ -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;