author | eilers <eilers> | 2004-09-05 15:46:47 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-09-05 15:46:47 (UTC) |
commit | 97a40bb7f35a8323dd99712bf014387add283177 (patch) (unidiff) | |
tree | ec50fbb430f00c86af6ca5bd7c6b94fa29cfe3b1 /libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |
parent | f8b02e2ae752ce98b8840735260c4e9b0ff25cb8 (diff) | |
download | opie-97a40bb7f35a8323dd99712bf014387add283177.zip opie-97a40bb7f35a8323dd99712bf014387add283177.tar.gz opie-97a40bb7f35a8323dd99712bf014387add283177.tar.bz2 |
Fixing really stupid caching bug.. Thanks to zecke who found it..
Removed cachefind in backend which isn't needed anymore and not a goot idea...
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index abfd944..221e977 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -833,57 +833,60 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
833 | 833 | ||
834 | return nonCustomMap; | 834 | return nonCustomMap; |
835 | } | 835 | } |
836 | 836 | ||
837 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ | 837 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ |
838 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const | 838 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const |
839 | { | 839 | { |
840 | // We want to get all contacts with one query. | 840 | // We want to get all contacts with one query. |
841 | // We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h). | 841 | // We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h). |
842 | // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned | 842 | // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned |
843 | // by using the cache.. | 843 | // by using the cache.. |
844 | QArray<int> cachelist = uidlist; | 844 | QArray<int> cachelist = uidlist; |
845 | OPimContact retContact; | ||
845 | 846 | ||
846 | odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; | 847 | odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; |
847 | 848 | ||
848 | QTime t; | 849 | QTime t; |
849 | t.start(); | 850 | t.start(); |
850 | 851 | ||
851 | int t2needed = 0; | 852 | int t2needed = 0; |
852 | int t3needed = 0; | 853 | int t3needed = 0; |
853 | QTime t2; | 854 | QTime t2; |
854 | t2.start(); | 855 | t2.start(); |
855 | FindQuery query( cachelist ); | 856 | FindQuery query( cachelist ); |
856 | OSQLResult res_noncustom = m_driver->query( &query ); | 857 | OSQLResult res_noncustom = m_driver->query( &query ); |
857 | t2needed = t2.elapsed(); | 858 | t2needed = t2.elapsed(); |
858 | 859 | ||
859 | QMap<int, QString> nonCustomMap; | 860 | QMap<int, QString> nonCustomMap; |
860 | QTime t3; | 861 | QTime t3; |
861 | t3.start(); | 862 | t3.start(); |
862 | OSQLResultItem resItem = res_noncustom.first(); | 863 | OSQLResultItem resItem = res_noncustom.first(); |
863 | do { | 864 | do { |
864 | OPimContact contact( fillNonCustomMap( resItem ) ); | 865 | OPimContact contact( fillNonCustomMap( resItem ) ); |
865 | contact.setExtraMap( requestCustom( contact.uid() ) ); | 866 | contact.setExtraMap( requestCustom( contact.uid() ) ); |
866 | odebug << "Caching uid: " << contact.uid() << oendl; | 867 | odebug << "Caching uid: " << contact.uid() << oendl; |
867 | cache( contact ); | 868 | cache( contact ); |
869 | if ( contact.uid() == uid ) | ||
870 | retContact = contact; | ||
868 | resItem = res_noncustom.next(); | 871 | resItem = res_noncustom.next(); |
869 | } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! | 872 | } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! |
870 | t3needed = t3.elapsed(); | 873 | t3needed = t3.elapsed(); |
871 | 874 | ||
872 | 875 | ||
873 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; | 876 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; |
874 | odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed | 877 | odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed |
875 | << " ms, mapping: " << t3needed << " ms" << oendl; | 878 | << " ms, mapping: " << t3needed << " ms" << oendl; |
876 | 879 | ||
877 | return cacheFind( uid ); | 880 | return retContact; |
878 | } | 881 | } |
879 | 882 | ||
880 | QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const | 883 | QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const |
881 | { | 884 | { |
882 | QMap<int, QString> nonCustomMap; | 885 | QMap<int, QString> nonCustomMap; |
883 | 886 | ||
884 | // Now loop through all columns | 887 | // Now loop through all columns |
885 | QStringList fieldList = OPimContactFields::untrfields( false ); | 888 | QStringList fieldList = OPimContactFields::untrfields( false ); |
886 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); | 889 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); |
887 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 890 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
888 | // Get data for the selected column and store it with the | 891 | // Get data for the selected column and store it with the |
889 | // corresponding id into the map.. | 892 | // corresponding id into the map.. |