{"action":"created","issue":{"url":"https://api.github.com/repos/QUItCoding/qnanopainter/issues/2","labels_url":"https://api.github.com/repos/QUItCoding/qnanopainter/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/QUItCoding/qnanopainter/issues/2/comments","events_url":"https://api.github.com/repos/QUItCoding/qnanopainter/issues/2/events","html_url":"https://github.com/QUItCoding/qnanopainter/issues/2","id":124373633,"number":2,"title":"wrong usage of QCache for font and images","user":{"login":"gunrot","id":12121419,"avatar_url":"https://avatars.githubusercontent.com/u/12121419?v=3","gravatar_id":"","url":"https://api.github.com/users/gunrot","html_url":"https://github.com/gunrot","followers_url":"https://api.github.com/users/gunrot/followers","following_url":"https://api.github.com/users/gunrot/following{/other_user}","gists_url":"https://api.github.com/users/gunrot/gists{/gist_id}","starred_url":"https://api.github.com/users/gunrot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunrot/subscriptions","organizations_url":"https://api.github.com/users/gunrot/orgs","repos_url":"https://api.github.com/users/gunrot/repos","events_url":"https://api.github.com/users/gunrot/events{/privacy}","received_events_url":"https://api.github.com/users/gunrot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-30T17:04:19Z","updated_at":"2015-12-30T22:11:10Z","closed_at":null,"body":"Either you or I have a misunderstanding in how QCache works.\r\nWhen reading documentation, i read that it takes ownership and deletes an item any time it wants.\r\nBut this way you cannot stay in sync with the font stored in fontstash. you also use new for data which is deleted with free. Also a font in use may not be in the cache, as any other insert can lead to removal and deletion. Next time you use this removed font you will add it again in font stash. \r\nOnly q implicit shared objects could be used by doing insert(key,new QImage(myImage)). .\r\ni made a change to fix that by not using the cache at all, but use nvgFindFont to find an existing font.\r\n\r\nsee commit ea9a287 at github.com/gunrot/qnanopainter ( also in the pull request now by accident, i don't have a proper understanding of this for now it seems)\r\n\r\nSimilar issues exist with the image caching, but there is no possibility in nanovg to find an image by name. So i would just change the QCache to a QMap to have a name to id mapping.\r\nThe current usage of Cache, will lead to images be forgotten in the nag store, as QCache will evict the dataeleemwnt but not remove the image from the store.so the next time the image is added agin in the store as it has been forgotten.\r\n \r\n\r\nI also do not  think the caching should be on item level, but should be globally shared. so items using the same font and images can shared them.\r\nBut as i understand it, each item has its itempainter, which holds its own nvg context ( storing fonts and images) and its own painter.\r\n\r\nThis architecture seems to be not efficient if i want to use about 100 quicknanoitems on the screen. especially if they use the same fonts and or images.\r\n\r\nso could the nvg context be shared between quicknanoitems?\r\n\r\nBest regards,\r\nGunnar Roth\r\n\r\n \r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/QUItCoding/qnanopainter/issues/comments/168082186","html_url":"https://github.com/QUItCoding/qnanopainter/issues/2#issuecomment-168082186","issue_url":"https://api.github.com/repos/QUItCoding/qnanopainter/issues/2","id":168082186,"user":{"login":"QUItCoding","id":16169635,"avatar_url":"https://avatars.githubusercontent.com/u/16169635?v=3","gravatar_id":"","url":"https://api.github.com/users/QUItCoding","html_url":"https://github.com/QUItCoding","followers_url":"https://api.github.com/users/QUItCoding/followers","following_url":"https://api.github.com/users/QUItCoding/following{/other_user}","gists_url":"https://api.github.com/users/QUItCoding/gists{/gist_id}","starred_url":"https://api.github.com/users/QUItCoding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QUItCoding/subscriptions","organizations_url":"https://api.github.com/users/QUItCoding/orgs","repos_url":"https://api.github.com/users/QUItCoding/repos","events_url":"https://api.github.com/users/QUItCoding/events{/privacy}","received_events_url":"https://api.github.com/users/QUItCoding/received_events","type":"User","site_admin":false},"created_at":"2015-12-30T22:11:10Z","updated_at":"2015-12-30T22:11:10Z","body":"Yes 10x10 items isn’t that much but as those are painting to separate FBOs Qt scene graph can’t batch the rendering that efficiently. But please test, haven’t tried more than few nano items at the same time."}}