diff options
Diffstat (limited to 'platform/windows/mupdfwinrt/Cache.cpp')
-rw-r--r-- | platform/windows/mupdfwinrt/Cache.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/platform/windows/mupdfwinrt/Cache.cpp b/platform/windows/mupdfwinrt/Cache.cpp index b129710f..d5108a7c 100644 --- a/platform/windows/mupdfwinrt/Cache.cpp +++ b/platform/windows/mupdfwinrt/Cache.cpp @@ -22,7 +22,6 @@ void Cache::Empty(fz_context *mu_ctx) cache_entry_t *old_entry = curr_entry; curr_entry = old_entry->next; fz_drop_display_list(mu_ctx, old_entry->dlist); - delete old_entry; } this->size = 0; @@ -49,7 +48,10 @@ void Cache::Add(int value, int width_in, int height_in, fz_display_list *dlist, tail = prev_entry; - /* Decrement the caches rc of this list */ + /* Decrement the caches rc of this list. It is gone from cache but + may still be in use by other threads, when threads are done they + should decrement and it should be freed at that time. See + ReleaseDisplayLists in muctx class */ fz_drop_display_list(mu_ctx, curr_entry->dlist); delete curr_entry; size--; @@ -76,8 +78,8 @@ void Cache::Add(int value, int width_in, int height_in, fz_display_list *dlist, head = new_entry; } size++; - /* We are going to use this item now */ - fz_keep_display_list(mu_ctx, new_entry->dlist); + /* Everytime we add an entry, we are also using it. Increment rc. See above */ + fz_keep_display_list(mu_ctx, dlist); } fz_display_list* Cache::Use(int value, int *width_out, int *height_out, fz_context *mu_ctx) @@ -93,7 +95,6 @@ fz_display_list* Cache::Use(int value, int *width_out, int *height_out, fz_conte } if (curr_entry != NULL) { - fz_keep_display_list(mu_ctx, curr_entry->dlist); /* Move this to the front */ if (curr_entry != head) { @@ -113,6 +114,9 @@ fz_display_list* Cache::Use(int value, int *width_out, int *height_out, fz_conte } *width_out = curr_entry->width; *height_out = curr_entry->height; + /* We must increment our reference to this one to ensure it is not + freed when removed from the cache. See above comments */ + fz_keep_display_list(mu_ctx, curr_entry->dlist); return curr_entry->dlist; } else |