Changeset 281

Show
Ignore:
Timestamp:
02/23/05 15:45:50 (4 years ago)
Author:
azrael
Message:

Updated version to 0.11

Fixed a crash when the conversion failed during a commit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Doxyfile

    r245 r281  
    2424# if some version control system is used. 
    2525 
    26 PROJECT_NUMBER = 0.10 
     26PROJECT_NUMBER = 0.11 
    2727 
    2828# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)  
  • trunk/configure.in

    r257 r281  
    33AC_PREREQ(2.58) 
    44AC_INIT(configure.in) 
    5 AM_INIT_AUTOMAKE(opensync, 0.10
     5AM_INIT_AUTOMAKE(opensync, 0.11
    66AM_CONFIG_HEADER(config.h) 
    77 
  • trunk/formats/vformats-xml/xml-vcard.c

    r279 r281  
    401401        EVCardAttribute *attr = NULL; 
    402402        xmlNode *root = osxml_node_get_root((xmlDoc *)input, "contact", error); 
    403         if (!root) 
     403        if (!root) { 
     404                osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get root element of xml-contact"); 
     405                osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); 
    404406                return FALSE; 
     407        } 
    405408         
    406409        g_type_init(); 
  • trunk/opensync/opensync_convert.c

    r279 r281  
    135135osync_bool osync_converter_invoke(OSyncFormatConverter *converter, OSyncChange *change, OSyncError **error) 
    136136{ 
    137         osync_trace(TRACE_ENTRY, "osync_converter_invoke(%p, %p, %p) %i", converter, change, error); 
     137        osync_trace(TRACE_ENTRY, "osync_converter_invoke(%p, %p, %p)", converter, change, error); 
    138138        osync_trace(TRACE_INTERNAL, "converter: Type: %i, source: %s, target %s", converter->type, converter->source_format->name, converter->target_format->name); 
    139139        char *data = NULL; 
     
    149149                //Invoke the converter and all extensions 
    150150                osync_conv_invoke_extensions(converter->source_format, FALSE, change); 
    151                 osync_bool free_input; 
    152                 ret = converter->convert_func(change->data, change->size, &data, &datasize, &free_input, error); 
    153  
    154                 if (converter->type == CONVERTER_DECAP) { 
    155                         if (!free_input) { 
    156                                 /* Duplicate the returned data, as the original data will be destroyed */ 
    157                                 if (!converter->target_format->copy_func) { 
    158                                         /* There is nothing we can do, here. The returned data is a reference, but 
    159                                          * we can't copy the data before destroying it 
    160                                          */ 
    161                                         osync_debug("OSYNC", 0, "Format %s don't have a copy function, but a no-copy converter was registered", converter->target_format->name); 
    162                                         osync_error_set(error, OSYNC_ERROR_GENERIC, "Format %s don't have a copy function, but a no-copy converter was registered", converter->target_format->name); 
    163                                         osync_trace(TRACE_EXIT_ERROR, "osync_converter_invoke: %s", osync_error_print(error)); 
    164                                         return FALSE; 
     151                osync_bool free_input = FALSE; 
     152                if ((ret = converter->convert_func(change->data, change->size, &data, &datasize, &free_input, error))) { 
     153                 
     154                        if (converter->type == CONVERTER_DECAP) { 
     155                                if (!free_input) { 
     156                                        /* Duplicate the returned data, as the original data will be destroyed */ 
     157                                        if (!converter->target_format->copy_func) { 
     158                                                /* There is nothing we can do, here. The returned data is a reference, but 
     159                                                 * we can't copy the data before destroying it 
     160                                                 */ 
     161                                                osync_debug("OSYNC", 0, "Format %s don't have a copy function, but a no-copy converter was registered", converter->target_format->name); 
     162                                                osync_error_set(error, OSYNC_ERROR_GENERIC, "Format %s don't have a copy function, but a no-copy converter was registered", converter->target_format->name); 
     163                                                osync_trace(TRACE_EXIT_ERROR, "osync_converter_invoke: %s", osync_error_print(error)); 
     164                                                return FALSE; 
     165                                        } 
     166                                        converter->target_format->copy_func(data, datasize, &data, &datasize); 
    165167                                } 
    166                                 converter->target_format->copy_func(data, datasize, &data, &datasize); 
    167168                        } 
     169                        /* Free the data, unless the converter took the ownership of the data */ 
     170                        if (free_input) { 
     171                                if (converter->source_format->destroy_func) { 
     172                                        converter->source_format->destroy_func(change->data, change->size); 
     173                                } else 
     174                                        osync_debug("OSYNC", 1, "Format %s don't have a destroy function. Possible memory leak", converter->source_format->name); 
     175                        } 
     176                        change->data = data; 
     177                        change->size = datasize; 
     178                         
     179                        osync_conv_invoke_extensions(converter->target_format, TRUE, change); 
    168180                } 
    169                 /* Free the data, unless the converter took the ownership of the data */ 
    170                 if (free_input) { 
    171                         if (converter->source_format->destroy_func) { 
    172                                 converter->source_format->destroy_func(change->data, change->size); 
    173                         } else 
    174                                 osync_debug("OSYNC", 1, "Format %s don't have a destroy function. Possible memory leak", converter->source_format->name); 
    175                 } 
    176                 change->data = data; 
    177                 change->size = datasize; 
    178                  
    179                 osync_conv_invoke_extensions(converter->target_format, TRUE, change); 
    180         } 
    181         osync_debug("OSYNC", 3, "Converting! replacing format %s with %s", converter->source_format->name, converter->target_format->name); 
    182         change->format = converter->target_format; 
    183         change->objtype = change->format->objtype; 
    184  
    185         if (ret) 
     181        } 
     182         
     183        if (ret) { 
     184                osync_debug("OSYNC", 3, "Converting! replacing format %s with %s", converter->source_format->name, converter->target_format->name); 
     185                change->format = converter->target_format; 
     186                change->objtype = change->format->objtype; 
    186187                osync_trace(TRACE_EXIT, "osync_converter_invoke: TRUE"); 
    187         else 
     188        } else 
    188189                osync_trace(TRACE_EXIT_ERROR, "osync_converter_invoke: %s", osync_error_print(error)); 
    189190        return ret; 
     
    467468         
    468469free_tree: 
    469         osync_trace(TRACE_INTERNAL, "Invoked detector for converter from TRUE1"); 
    470470        g_list_free(tree->unused); 
    471         osync_trace(TRACE_INTERNAL, "Invoked detector for converter from  TRUE2"); 
    472471        g_list_free(tree->search); 
    473         osync_trace(TRACE_INTERNAL, "Invoked detector for converter from  TRUE3 %p", tree); 
    474472        g_free(tree); 
    475         osync_trace(TRACE_INTERNAL, "Invoked detector for converter from  TRUE4"); 
    476473        if (ret) 
    477474                osync_trace(TRACE_EXIT, "osync_conv_find_path_fn: TRUE"); 
     
    617614/** Convert a change to the nearest format sink on a member 
    618615 */ 
    619 osync_bool osync_change_convert_member_sink(OSyncFormatEnv *env, OSyncChange *change, OSyncMember *memb
    620 { 
    621         return osync_conv_convert_fn(env, change, target_fn_membersink, memb, NULL); 
     616osync_bool osync_change_convert_member_sink(OSyncFormatEnv *env, OSyncChange *change, OSyncMember *memb, OSyncError **error
     617{ 
     618        return osync_conv_convert_fn(env, change, target_fn_membersink, memb, error); 
    622619} 
    623620 
     
    871868 
    872869        OSyncError *error = NULL; 
    873         osync_change_convert_to_common(leftchange, &error); 
    874         if (error) { 
     870        if (!osync_change_convert_to_common(leftchange, &error)) { 
    875871                osync_trace(TRACE_INTERNAL, "osync_change_compare: %s", osync_error_print(&error)); 
    876872                osync_error_free(&error); 
     
    878874                return CONV_DATA_MISMATCH; 
    879875        } 
    880         osync_change_convert_to_common(rightchange, &error); 
    881         if (error) { 
     876        if (!osync_change_convert_to_common(rightchange, &error)) { 
    882877                osync_trace(TRACE_INTERNAL, "osync_change_compare: %s", osync_error_print(&error)); 
    883878                osync_error_free(&error); 
     
    947942                osync_error_set(error, OSYNC_ERROR_GENERIC, "The change has no objtype"); 
    948943                osync_trace(TRACE_EXIT_ERROR, "osync_change_convert_to_common: %s", osync_error_print(error)); 
     944                return FALSE; 
    949945        } 
    950946        OSyncFormatEnv *env = change->objtype->env; 
  • trunk/opensync/opensync_format_internals.h

    r279 r281  
    105105osync_bool osync_conv_convert_fn(OSyncFormatEnv *env, OSyncChange *change, OSyncPathTargetFn target_fn, const void *fndata, OSyncError **error); 
    106106osync_bool osync_conv_convert_fmtlist(OSyncFormatEnv *env, OSyncChange *change, GList/*OSyncObjFormat * */ *targets); 
    107 osync_bool osync_change_convert_member_sink(OSyncFormatEnv *env, OSyncChange *change, OSyncMember *memb); 
     107osync_bool osync_change_convert_member_sink(OSyncFormatEnv *env, OSyncChange *change, OSyncMember *memb, OSyncError **error); 
    108108OSyncDataDetector *osync_env_find_detector(OSyncEnv *env, const char *sourcename, const char *targetname); 
    109109osync_bool osync_conv_objtype_is_any(const char *objstr); 
  • trunk/opensync/opensync_member.c

    r279 r281  
    517517                 * because not detection/conversion will be run 
    518518                 */ 
    519                 if (!osync_change_convert_member_sink(env, change, member)) { 
     519                OSyncError *error = NULL; 
     520                if (!osync_change_convert_member_sink(env, change, member, &error)) { 
    520521                        osync_debug("OSYNC", 0, "Unable to convert to any format on the plugin"); 
    521522                        osync_context_report_error(context, OSYNC_ERROR_CONVERT, "Unable to convert change"); 
     523                        osync_error_free(&error); 
    522524                        return; 
    523525                }