« Return to Thread: patch to fix iterators in khomeview (for kde4 version)

patch to fix iterators in khomeview (for kde4 version)

by Bugzilla from onet.cristian@gmail.com :: Rate this Message:

Reply to Author | View in Thread

Hi,

This is a patch for the KDE4 version of kmymoney (from the KDE repository) but
I think that it could also be applied to the KDE3 development version. It fixes
an invalid iterator, a problem that does not seem to manifests itself on qt3.
Not at least the KDE4 version starts and loads my kmymoney file.
By the way what is the status of the sources in the KDE repository? Could I
help porting? If yes is this the right place to send patches? I would really
like kmymoney to be ported on KDE4 and I am willing to help to make it happen.

--
Regards,

Cristian Oneţ

[fix_iterator_in_home_view.patch]

Index: kmymoney2/views/khomeview.cpp
===================================================================
--- kmymoney2/views/khomeview.cpp (revision 989181)
+++ kmymoney2/views/khomeview.cpp (working copy)
@@ -681,7 +681,7 @@
   // get list of all accounts
   file->accountList(accounts);
   for(it = accounts.begin(); it != accounts.end();) {
-    prevIt = it;
+    bool bRemoveAccount = false;
     if(!(*it).isClosed() || showClosedAccounts) {
       switch((*it).accountType()) {
         case MyMoneyAccount::Expense:
@@ -689,7 +689,7 @@
           // never show a category account
           // Note: This might be different in a future version when
           //       the homepage also shows category based information
-          it = accounts.erase(it);
+          bRemoveAccount = true;
           break;
 
         // Asset and Liability accounts are only shown if they
@@ -700,7 +700,7 @@
           // if preferred accounts are requested, then keep in list
           if((*it).value("PreferredAccount") != "Yes"
           || (type & Preferred) == 0) {
-            it = accounts.erase(it);
+            bRemoveAccount = true;
           }
           break;
 
@@ -714,36 +714,37 @@
           switch(type & (Payment | Preferred)) {
             case Payment:
               if((*it).value("PreferredAccount") == "Yes")
-                it = accounts.erase(it);
+                bRemoveAccount = true;
               break;
 
             case Preferred:
               if((*it).value("PreferredAccount") != "Yes")
-                it = accounts.erase(it);
+                bRemoveAccount = true;
               break;
 
             case Payment | Preferred:
               break;
 
             default:
-              it = accounts.erase(it);
+              bRemoveAccount = true;
               break;
           }
           break;
 
         // filter all accounts that are not used on homepage views
         default:
-          it = accounts.erase(it);
+          bRemoveAccount = true;
           break;
       }
 
     } else if((*it).isClosed() || (*it).isInvest()) {
       // don't show if closed or a stock account
-      it = accounts.erase(it);
+      bRemoveAccount = true;
     }
 
-    // if we still point to the same account we keep it in the list and move on ;-)
-    if(prevIt == it) {
+    if (bRemoveAccount)
+      it = accounts.erase(it);
+    else {
       QString key = (*it).name();
       if(!nameIdx.contains(key)) {
         nameIdx[key] = *it;



------------------------------------------------------------------------------

_______________________________________________
KMyMoney2-developer mailing list
KMyMoney2-developer@...
https://lists.sourceforge.net/lists/listinfo/kmymoney2-developer

signature.asc (205 bytes) Download Attachment

 « Return to Thread: patch to fix iterators in khomeview (for kde4 version)