summaryrefslogtreecommitdiff
authoreilers <eilers>2004-09-05 15:46:47 (UTC)
committer eilers <eilers>2004-09-05 15:46:47 (UTC)
commit97a40bb7f35a8323dd99712bf014387add283177 (patch) (unidiff)
treeec50fbb430f00c86af6ca5bd7c6b94fa29cfe3b1
parentf8b02e2ae752ce98b8840735260c4e9b0ff25cb8 (diff)
downloadopie-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 (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp5
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.h4
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h22
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp20
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h2
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h4
6 files changed, 25 insertions, 32 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
@@ -844,2 +844,3 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons
844 QArray<int> cachelist = uidlist; 844 QArray<int> cachelist = uidlist;
845 OPimContact retContact;
845 846
@@ -867,2 +868,4 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons
867 cache( contact ); 868 cache( contact );
869 if ( contact.uid() == uid )
870 retContact = contact;
868 resItem = res_noncustom.next(); 871 resItem = res_noncustom.next();
@@ -876,3 +879,3 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons
876 879
877 return cacheFind( uid ); 880 return retContact;
878} 881}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
index 4f81735..28d9746 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
@@ -74,4 +74,4 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
74 74
75 OPimContact find ( int uid ) const; 75 OPimContact find( int uid ) const;
76 OPimContact find( int uid, const QArray<int>&, uint cur, Frontend::CacheDirection ) const; 76 OPimContact find( int uid, const QArray<int>& items, uint cur, Frontend::CacheDirection ) const;
77 77
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 15a7b7f..26af762 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -95,5 +95,5 @@ public:
95 */ 95 */
96 virtual T find(int uid )const = 0; 96 virtual T find( int uid )const = 0;
97 97
98 virtual T find(int uid, const QArray<int>& items, 98 virtual T find( int uid, const QArray<int>& items,
99 uint current, typename Frontend::CacheDirection ) const; 99 uint current, typename Frontend::CacheDirection ) const;
@@ -133,9 +133,2 @@ protected:
133 133
134 /**
135 * Returns the element with given uid out of the cache.
136 * Returns empty element if nothing was found.
137 * <b>Attention:</b> This just works if we have a frontend which contains the cache !
138 */
139 T cacheFind( int uid ) const;
140
141 /** 134 /**
@@ -175,11 +168,2 @@ void OPimAccessBackend<T>::cache( const T& t )const {
175 168
176template <class T>
177T OPimAccessBackend<T>::cacheFind( int uid )const {
178 if ( ! m_front ){
179 qWarning ( "No frontend assigned ! Therefore we cannot access the cache to return the right element!" );
180 return T();
181 }
182
183 return m_front->cacheFind( uid );
184}
185 169
@@ -193,3 +177,3 @@ T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
193 uint, typename Frontend::CacheDirection ) const{ 177 uint, typename Frontend::CacheDirection ) const{
194 qDebug( "*** Lookahead feature not supported. Fallback to default find!" ); 178 qDebug( "*** Lookahead feature not supported. Fallback to default find!!" );
195 return find( uid ); 179 return find( uid );
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 12a8bea..4e3e47b 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -456,3 +456,3 @@ OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
456 FindQuery query( uid ); 456 FindQuery query( uid );
457 return todo( m_driver->query(&query) ); 457 return parseResultAndCache( uid, m_driver->query(&query) );
458 458
@@ -494,4 +494,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
494 494
495 todo( res ); //FIXME: Don't like polymorphism here. It makes the code hard to read here..(eilers) 495 return parseResultAndCache( uid, res );
496 return cacheFind( uid );
497} 496}
@@ -632,3 +631,3 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
632} 631}
633OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ 632OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
634 if ( res.state() == OSQLResult::Failure ) { 633 if ( res.state() == OSQLResult::Failure ) {
@@ -638,2 +637,4 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
638 637
638 OPimTodo retTodo;
639
639 OSQLResultItem::ValueList list = res.results(); 640 OSQLResultItem::ValueList list = res.results();
@@ -647,5 +648,8 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
647 odebug << "caching" << oendl; 648 odebug << "caching" << oendl;
648 cache( todo( (*it) ) ); 649 OPimTodo newTodo = todo( (*it) );
650 cache( newTodo );
651 if ( newTodo.uid() == uid )
652 retTodo = newTodo;
649 } 653 }
650 return to; 654 return retTodo;
651} 655}
@@ -709,5 +713,7 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
709} 713}
714
715// FIXME: Where is the difference to "find" ? (eilers)
710OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const { 716OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
711 FindQuery find( uid ); 717 FindQuery find( uid );
712 return todo( m_driver->query(&find) ); 718 return parseResultAndCache( uid, m_driver->query(&find) );
713} 719}
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 0cc7722..415f791 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -77,3 +77,3 @@ private:
77 inline bool date( QDate& date, const QString& )const; 77 inline bool date( QDate& date, const QString& )const;
78 inline OPimTodo todo( const Opie::DB::OSQLResult& )const; 78 inline OPimTodo parseResultAndCache( int uid, const Opie::DB::OSQLResult& )const;
79 inline OPimTodo todo( Opie::DB::OSQLResultItem& )const; 79 inline OPimTodo todo( Opie::DB::OSQLResultItem& )const;
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6f01b46..7ab1ea5 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -121,3 +121,3 @@ public:
121 */ 121 */
122 virtual T find( int uid )const; 122 T find( int uid )const;
123 123
@@ -126,3 +126,3 @@ public:
126 */ 126 */
127 virtual T find( int uid, const QArray<int>&, 127 T find( int uid, const QArray<int>&,
128 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 128 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;