summaryrefslogtreecommitdiff
authoreilers <eilers>2004-09-05 15:46:47 (UTC)
committer eilers <eilers>2004-09-05 15:46:47 (UTC)
commit97a40bb7f35a8323dd99712bf014387add283177 (patch) (side-by-side diff)
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
QArray<int> cachelist = uidlist;
+ OPimContact retContact;
@@ -867,2 +868,4 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons
cache( contact );
+ if ( contact.uid() == uid )
+ retContact = contact;
resItem = res_noncustom.next();
@@ -876,3 +879,3 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons
- return cacheFind( uid );
+ return retContact;
}
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 {
- OPimContact find ( int uid ) const;
- OPimContact find( int uid, const QArray<int>&, uint cur, Frontend::CacheDirection ) const;
+ OPimContact find( int uid ) const;
+ OPimContact find( int uid, const QArray<int>& items, uint cur, Frontend::CacheDirection ) const;
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:
*/
- virtual T find(int uid )const = 0;
+ virtual T find( int uid )const = 0;
- virtual T find(int uid, const QArray<int>& items,
+ virtual T find( int uid, const QArray<int>& items,
uint current, typename Frontend::CacheDirection ) const;
@@ -133,9 +133,2 @@ protected:
- /**
- * Returns the element with given uid out of the cache.
- * Returns empty element if nothing was found.
- * <b>Attention:</b> This just works if we have a frontend which contains the cache !
- */
- T cacheFind( int uid ) const;
-
/**
@@ -175,11 +168,2 @@ void OPimAccessBackend<T>::cache( const T& t )const {
-template <class T>
-T OPimAccessBackend<T>::cacheFind( int uid )const {
- if ( ! m_front ){
- qWarning ( "No frontend assigned ! Therefore we cannot access the cache to return the right element!" );
- return T();
- }
-
- return m_front->cacheFind( uid );
-}
@@ -193,3 +177,3 @@ T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
uint, typename Frontend::CacheDirection ) const{
- qDebug( "*** Lookahead feature not supported. Fallback to default find!" );
+ qDebug( "*** Lookahead feature not supported. Fallback to default find!!" );
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{
FindQuery query( uid );
- return todo( m_driver->query(&query) );
+ return parseResultAndCache( uid, m_driver->query(&query) );
@@ -494,4 +494,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
- todo( res ); //FIXME: Don't like polymorphism here. It makes the code hard to read here..(eilers)
- return cacheFind( uid );
+ return parseResultAndCache( uid, res );
}
@@ -632,3 +631,3 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
}
-OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
+OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
if ( res.state() == OSQLResult::Failure ) {
@@ -638,2 +637,4 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
+ OPimTodo retTodo;
+
OSQLResultItem::ValueList list = res.results();
@@ -647,5 +648,8 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
odebug << "caching" << oendl;
- cache( todo( (*it) ) );
+ OPimTodo newTodo = todo( (*it) );
+ cache( newTodo );
+ if ( newTodo.uid() == uid )
+ retTodo = newTodo;
}
- return to;
+ return retTodo;
}
@@ -709,5 +713,7 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
}
+
+// FIXME: Where is the difference to "find" ? (eilers)
OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
FindQuery find( uid );
- return todo( m_driver->query(&find) );
+ return parseResultAndCache( uid, m_driver->query(&find) );
}
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:
inline bool date( QDate& date, const QString& )const;
- inline OPimTodo todo( const Opie::DB::OSQLResult& )const;
+ inline OPimTodo parseResultAndCache( int uid, const Opie::DB::OSQLResult& )const;
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:
*/
- virtual T find( int uid )const;
+ T find( int uid )const;
@@ -126,3 +126,3 @@ public:
*/
- virtual T find( int uid, const QArray<int>&,
+ T find( int uid, const QArray<int>&,
uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;