Changeset 672

Show
Ignore:
Timestamp:
09/02/05 21:40:34 (3 years ago)
Author:
ehabkost
Message:

Fix plugin bug that made it try to update the hashtable _after_ it
already reported success on commit_change() for vcards. It was causing
hard to reproduce crashes

Location:
plugins/kdepim/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • plugins/kdepim/src/kaddrbook.cpp

    r557 r672  
    162162}*/ 
    163163 
    164 bool KContactDataSource::vcard_access(OSyncContext *ctx, OSyncChange *chg) 
     164/** vcard access method 
     165 * 
     166 * This method is used by both access() and commit_change() method, 
     167 * so it shouldn't call osync_context_report_success(). On success, 
     168 * it should just return true and let the caller report success() to 
     169 * OpenSync 
     170 */ 
     171bool KContactDataSource::__vcard_access(OSyncContext *ctx, OSyncChange *chg) 
    165172{ 
    166173        osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ctx, chg); 
     
    228235        } 
    229236         
    230         osync_context_report_success(ctx); 
    231237        osync_trace(TRACE_EXIT, "%s", __func__); 
    232238        return TRUE; 
    233239} 
     240 
     241bool KContactDataSource::vcard_access(OSyncContext *ctx, OSyncChange *chg) 
     242{ 
     243        if (!__vcard_access(ctx, chg)) 
     244                return false; 
     245 
     246        osync_context_report_success(ctx); 
     247        return true; 
     248} 
     249 
     250bool KContactDataSource::vcard_commit_change(OSyncContext *ctx, OSyncChange *chg) 
     251{ 
     252    if ( !__vcard_access(ctx, chg) ) 
     253        return false; 
     254 
     255    osync_hashtable_update_hash(hashtable, chg); 
     256    osync_context_report_success(ctx); 
     257    return true; 
     258} 
  • plugins/kdepim/src/kaddrbook.h

    r455 r672  
    3636        OSyncHashTable *hashtable; 
    3737        OSyncMember *member; 
     38 
     39        bool __vcard_access(OSyncContext *ctx, OSyncChange *chg); 
     40 
    3841    public: 
    3942        KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable); 
     
    4447        bool contact_get_changeinfo(OSyncContext *ctx); 
    4548        bool vcard_access(OSyncContext *ctx, OSyncChange *chg); 
     49        bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg); 
    4650                bool connected; 
    4751}; 
  • plugins/kdepim/src/kdepim_impl.cpp

    r475 r672  
    210210        { 
    211211                        if (kaddrbook) 
    212                                 if (kaddrbook->vcard_access(ctx, chg)) 
    213                         osync_hashtable_update_hash(hashtable, chg); 
    214                 else 
    215                         return FALSE; 
     212                                return kaddrbook->vcard_commit_change(ctx, chg); 
    216213                        else { 
    217214                                osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No addressbook loaded");