hgcacheproxymodel/src/hgdataprovidermodel.cpp
changeset 3 c863538fcbb6
parent 2 49c70dcc3f17
child 5 4fa04caf0f43
--- a/hgcacheproxymodel/src/hgdataprovidermodel.cpp	Fri May 14 16:57:01 2010 +0300
+++ b/hgcacheproxymodel/src/hgdataprovidermodel.cpp	Thu May 27 13:59:05 2010 +0300
@@ -13,7 +13,7 @@
 *
 * Description:
 *
-*  Version     : %version: 6 %
+*  Version     : %version: 9 %
 */
 #include <e32debug.h>
 #include <QVariant>
@@ -149,6 +149,10 @@
 
 void HgDataProviderModel::clearCache()
 {
+    for ( int i=0; i<count(); i++){
+        releasePixmap(i);
+    }
+    
     qDeleteAll( mCache->begin(), mCache->end() );
     mCache->clear();
 }
@@ -162,7 +166,7 @@
 {
     bool change(false);
     if (list && list->count() && pos >=0 && pos<count() && mCache->at(pos)) {
-        while(list->count()){
+        while(list->count()>0){
             QPair< QVariant, int > pair = list->takeFirst();
             change = update(pos, pair.first, pair.second, true)|change;
         }
@@ -239,10 +243,8 @@
 
 void HgDataProviderModel::doInsertItem(int pos, QList< QPair< QVariant, int > >* list, bool silent)
 {
-    if (pos >mCache->count()){
-        pos = mCache->count();
-    } else if (pos <0){
-        pos = 0;
+    if (pos >mCache->count() || pos <0){
+        return;
     }
     
     if ( !silent){
@@ -267,9 +269,9 @@
 
 void HgDataProviderModel::removeItems(int pos, int size)
 {
-    if (pos >mCache->count())
+    if (pos >=mCache->count()){
         return;
-    else if (pos <0){
+    } else if (pos <0){
         size = size + pos; //pos <0
         pos = 0;
     }