Bool WQuerySaveSym( WMenuEditInfo *einfo, Bool force_exit ) { int ret; UINT style; char *title; char *text; if( einfo == NULL || !einfo->info->stand_alone ) { return( TRUE ); } if( !WRIsHashTableDirty( einfo->info->symbol_table ) ) { return( TRUE ); } if( force_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } title = WCreateEditTitle( einfo ); text = WAllocRCString( W_UPDATEMODIFIEDSYM ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WMemFree( title ); } if( ret == IDYES ) { if( einfo->info->symbol_file == NULL ) { char *fname; if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } einfo->info->symbol_file = WCreateSymName( fname ); } return( WSaveSymbols( einfo, einfo->info->symbol_table, &einfo->info->symbol_file, FALSE ) ); } else if( ret == IDCANCEL ) { return( FALSE ); } return( TRUE ); }
bool WSaveObject( WAccelEditInfo *einfo, bool get_name, bool save_into ) { bool ok, data_saved; void *old_data; size_t old_size; data_saved = FALSE; WSetWaitCursor( einfo->win, TRUE ); ok = (einfo != NULL); if( ok ) { if( einfo->info->res_name == NULL ) { WDisplayErrorMsg( W_RESHASNONAME ); ok = false; } else { if( !WRIsDefaultHashTable( einfo->info->symbol_table ) && (get_name || WRIsHashTableDirty( einfo->info->symbol_table )) ) { if( einfo->info->symbol_file == NULL ) { char *fname; if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } einfo->info->symbol_file = WCreateSymName( fname ); } ok = WSaveSymbols( einfo, einfo->info->symbol_table, &einfo->info->symbol_file, get_name ); } if( ok ) { old_data = einfo->info->data; old_size = einfo->info->data_size; data_saved = TRUE; WMakeDataFromAccelTable( einfo->tbl, &einfo->info->data, &einfo->info->data_size ); ok = (einfo->info->data != NULL && einfo->info->data_size != 0); if( !ok ) { WDisplayErrorMsg( W_ACCELISEMPTY ); } else { if( save_into ) { ok = WSaveObjectInto( einfo ); } else { ok = WSaveObjectAs( get_name, einfo ); } if( einfo->info->data != NULL ) { WRMemFree( einfo->info->data ); einfo->info->data = NULL; einfo->info->data_size = 0; } } } } } if( ok && einfo->info->stand_alone ) { einfo->info->modified = false; } if( data_saved ) { einfo->info->data = old_data; einfo->info->data_size = old_size; } WSetWaitCursor( einfo->win, FALSE ); return( ok ); }