From 37be9d531882d99db474915ee14ab7693146f794 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 28 Oct 2012 14:49:29 +0100 Subject: [PATCH] Fix bug in osdvector --- osdvector.cc | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/osdvector.cc b/osdvector.cc index a1ae4f3..fadd161 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -224,22 +224,42 @@ void OsdVector::removeImageRef(const ImageIndex ref) void OsdVector::cleanupOrphanedRefs() { // Do some garbage collection - map::iterator iitty=images_ref.begin(); - while (iitty!=images_ref.end()) { - int count=(*iitty).second; + + map::iterator mitty=monobitmaps.begin(); + while (mitty!=monobitmaps.end()) { + map::iterator curitty=images_ref.find((*mitty).second); + int count=(*curitty).second; + if (count==0) { + ImageIndex ref=(*curitty).first; + monobitmaps.erase(mitty++); + images_ref.erase(curitty++); + destroyImageRef(ref); + } else ++mitty; + } + + map::iterator jitty=jpegs.begin(); + while (jitty!=jpegs.end()) { + map::iterator curitty=images_ref.find((*jitty).second); + int count=(*curitty).second; if (count==0) { - ImageIndex ref=(*iitty).first; - images_ref.erase(iitty++); + ImageIndex ref=(*curitty).first; + jpegs.erase(jitty++); + images_ref.erase(curitty++); destroyImageRef(ref); - } else ++iitty; + } else ++jitty; } - map::iterator sitty=styles_ref.begin(); - while (sitty!=styles_ref.end()) { - int count=(*sitty).second; + + + map,unsigned int>::iterator sitty=styles.begin(); + while (sitty!=styles.end()) { + map::iterator curitty=styles_ref.find((*sitty).second); + int count=(*curitty).second; if (count==0) { - unsigned int ref=(*sitty).first; - styles_ref.erase(sitty++); + unsigned int ref=(*curitty).first; + styles.erase(sitty++); + styles_ref.erase(curitty++); destroyStyleRef(ref); + } else ++sitty; } -- 2.39.5