From b8e8c0e325d213f2dcf4adad5506989fa224716e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Jan 2019 23:24:20 +1100 Subject: Cleanup: comment line length (editors) Prevents clang-format wrapping text before comments. --- source/blender/editors/space_file/file_draw.c | 3 +- source/blender/editors/space_file/file_ops.c | 34 ++++++---- source/blender/editors/space_file/filelist.c | 96 ++++++++++++++++++--------- source/blender/editors/space_file/filesel.c | 3 +- source/blender/editors/space_file/fsmenu.c | 7 +- 5 files changed, 94 insertions(+), 49 deletions(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 93e10704c0c..73c670b09ac 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -310,7 +310,8 @@ static void file_draw_string( BLI_strncpy(fname, string, FILE_MAXFILE); UI_text_clip_middle_ex(&fs, fname, width, UI_DPI_ICON_SIZE, sizeof(fname), '\0'); - /* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict (for buttons it works) */ + /* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict + * (for buttons it works) */ rect.xmin = sx; rect.xmax = (int)(sx + ceil(width + 5.0f / UI_DPI_FAC)); rect.ymin = sy - height; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index ea73026020d..07e223c4534 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -443,7 +443,8 @@ static int file_box_select_exec(bContext *C, wmOperator *op) ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, false, false); - /* unselect '..' parent entry - it's not supposed to be selected if more than one file is selected */ + /* unselect '..' parent entry - it's not supposed to be selected if more than + * one file is selected */ filelist_entry_select_index_set(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); if (FILE_SELECT_DIR == ret) { @@ -507,7 +508,8 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill, do_diropen); if (extend) { - /* unselect '..' parent entry - it's not supposed to be selected if more than one file is selected */ + /* unselect '..' parent entry - it's not supposed to be selected if more + * than one file is selected */ filelist_entry_select_index_set(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); } @@ -571,10 +573,11 @@ static bool file_walk_select_selection_set( deselect = (fill || other_site == -1 || !filelist_entry_select_index_get(files, other_site, CHECK_ALL)); - /* don't change highlight_file here since we either want to deselect active or we want to - * walk through a block of selected files without selecting/deselecting anything */ + /* don't change highlight_file here since we either want to deselect active or we want + * to walk through a block of selected files without selecting/deselecting anything */ params->active_file = active_new; - /* but we want to change active if we use fill (needed to get correct selection bounds) */ + /* but we want to change active if we use fill + * (needed to get correct selection bounds) */ if (deselect && fill) { active = active_new; } @@ -606,7 +609,8 @@ static bool file_walk_select_selection_set( /* highlight the active walker file for extended selection for better visual feedback */ params->highlight_file = params->active_file; - /* unselect '..' parent entry - it's not supposed to be selected if more than one file is selected */ + /* unselect '..' parent entry - it's not supposed to be selected if more + * than one file is selected */ filelist_entry_select_index_set(files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); } else { @@ -824,7 +828,8 @@ void FILE_OT_select_all(wmOperatorType *ot) /* ---------- BOOKMARKS ----------- */ -/* Note we could get rid of this one, but it's used by some addon so... Does not hurt keeping it around for now. */ +/* Note we could get rid of this one, but it's used by some addon so... + * Does not hurt keeping it around for now. */ static int bookmark_select_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); @@ -1207,7 +1212,8 @@ void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, ch Main *bmain = CTX_data_main(C); PropertyRNA *prop; - BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */ + /* XXX, not real length */ + BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) { if (RNA_property_boolean_get(op->ptr, prop)) { @@ -1243,7 +1249,8 @@ void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, ch num_files++; } } - /* make sure the file specified in the filename button is added even if no files selected */ + /* make sure the file specified in the filename button is added even if no + * files selected */ if (0 == num_files) { RNA_property_collection_add(op->ptr, prop, &itemptr); RNA_string_set(&itemptr, "name", sfile->params->file); @@ -1263,7 +1270,8 @@ void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, ch } } - /* make sure the directory specified in the button is added even if no directory selected */ + /* make sure the directory specified in the button is added even if no + * directory selected */ if (0 == num_dirs) { RNA_property_collection_add(op->ptr, prop, &itemptr); RNA_string_set(&itemptr, "name", sfile->params->dir); @@ -1804,7 +1812,8 @@ int file_directory_new_exec(bContext *C, wmOperator *op) BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); /* set timer to smoothly view newly generated file */ - sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ + /* max 30 frs/sec */ + sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0); sfile->scroll_offset = 0; /* reload dir to make sure we're seeing what's in the directory */ @@ -2001,7 +2010,8 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg BLI_filename_make_safe(sfile->params->file); if (matches) { - /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ + /* replace the pattern (or filename that the user typed in, + * with the first selected file of the match */ BLI_strncpy(sfile->params->file, matched_file, sizeof(sfile->params->file)); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 218c7dcdb42..75b5218d816 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -165,7 +165,8 @@ int folderlist_clear_next(struct SpaceFile *sfile) if (!sfile->folders_next) return 0; - /* if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next */ + /* if previous_folder, next_folder or refresh_folder operators are executed + * it doesn't clear folder_next */ folder = sfile->folders_prev->last; if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) return 0; @@ -208,19 +209,24 @@ ListBase *folderlist_duplicate(ListBase *folderlist) typedef struct FileListInternEntry { struct FileListInternEntry *next, *prev; - char uuid[16]; /* ASSET_UUID_LENGTH */ + /** ASSET_UUID_LENGTH */ + char uuid[16]; - int typeflag; /* eFileSel_File_Types */ - int blentype; /* ID type, in case typeflag has FILE_TYPE_BLENDERLIB set. */ + /** eFileSel_File_Types */ + int typeflag; + /** ID type, in case typeflag has FILE_TYPE_BLENDERLIB set. */ + int blentype; char *relpath; - char *name; /* not strictly needed, but used during sorting, avoids to have to recompute it there... */ + /** not strictly needed, but used during sorting, avoids to have to recompute it there... */ + char *name; BLI_stat_t st; } FileListInternEntry; typedef struct FileListIntern { - ListBase entries; /* FileListInternEntry items. */ + /** FileListInternEntry items. */ + ListBase entries; FileListInternEntry **filtered; char curr_uuid[16]; /* Used to generate uuid during internal listing. */ @@ -235,7 +241,8 @@ typedef struct FileListEntryCache { /* This one gathers all entries from both block and misc caches. Used for easy bulk-freing. */ ListBase cached_entries; - /* Block cache: all entries between start and end index. used for part of the list on display. */ + /* Block cache: all entries between start and end index. + * used for part of the list on display. */ FileDirEntry **block_entries; int block_start_index, block_end_index, block_center_index, block_cursor; @@ -910,7 +917,8 @@ static int filelist_geticon_ex( return ICON_FILE_BLEND; } else if (is_main) { - /* Do not return icon for folders if icons are not 'main' draw type (e.g. when used over previews). */ + /* Do not return icon for folders if icons are not 'main' draw type + * (e.g. when used over previews). */ return ICON_FILE_FOLDER; } } @@ -1002,7 +1010,8 @@ static void filelist_entry_clear(FileDirEntry *entry) if (entry->image) { IMB_freeImBuf(entry->image); } - /* For now, consider FileDirEntryRevision::poin as not owned here, so no need to do anything about it */ + /* For now, consider FileDirEntryRevision::poin as not owned here, + * so no need to do anything about it */ if (!BLI_listbase_is_empty(&entry->variants)) { FileDirEntryVariant *var; @@ -1348,7 +1357,8 @@ void filelist_free(struct FileList *filelist) return; } - filelist_clear_ex(filelist, false, false); /* No need to clear cache & selection_state, we free them anyway. */ + /* No need to clear cache & selection_state, we free them anyway. */ + filelist_clear_ex(filelist, false, false); filelist_cache_free(&filelist->filelist_cache); if (filelist->selection_state) { @@ -1561,7 +1571,8 @@ int filelist_file_findpath(struct FileList *filelist, const char *filename) } /* XXX TODO Cache could probably use a ghash on paths too? Not really urgent though. - * This is only used to find again renamed entry, annoying but looks hairy to get rid of it currently. */ + * This is only used to find again renamed entry, + * annoying but looks hairy to get rid of it currently. */ for (fidx = 0; fidx < filelist->filelist.nbr_entries_filtered; fidx++) { FileListInternEntry *entry = filelist->filelist_intern.filtered[fidx]; @@ -1602,7 +1613,8 @@ FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const int uuid void filelist_file_cache_slidingwindow_set(FileList *filelist, size_t window_size) { - /* Always keep it power of 2, in [256, 8192] range for now, cache being app. twice bigger than requested window. */ + /* Always keep it power of 2, in [256, 8192] range for now, + * cache being app. twice bigger than requested window. */ size_t size = 256; window_size *= 2; @@ -1723,8 +1735,9 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index) else { // printf("Partial Recaching!\n"); - /* At this point, we know we keep part of currently cached entries, so update previews if needed, - * and remove everything from working queue - we'll add all newly needed entries at the end. */ + /* At this point, we know we keep part of currently cached entries, so update previews + * if needed, and remove everything from working queue - we'll add all newly needed + * entries at the end. */ if (cache->flags & FLC_PREVIEWS_ACTIVE) { filelist_cache_previews_update(filelist); filelist_cache_previews_clear(cache); @@ -1737,7 +1750,9 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index) int size2 = 0; int idx1 = cache->block_cursor, idx2 = 0; -// printf("\tcache releasing: [%d:%d] (%d, %d)\n", cache->block_start_index, cache->block_start_index + size1, cache->block_cursor, size1); +// printf("\tcache releasing: [%d:%d] (%d, %d)\n", +// cache->block_start_index, cache->block_start_index + size1, +// cache->block_cursor, size1); if (idx1 + size1 > cache_size) { size2 = idx1 + size1 - cache_size; @@ -1754,7 +1769,8 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index) int size2 = 0; int idx1, idx2 = 0; -// printf("\tcache releasing: [%d:%d] (%d)\n", cache->block_end_index - size1, cache->block_end_index, cache->block_cursor); +// printf("\tcache releasing: [%d:%d] (%d)\n", +// cache->block_end_index - size1, cache->block_end_index, cache->block_cursor); idx1 = (cache->block_cursor + end_index - cache->block_start_index) % cache_size; if (idx1 + size1 > cache_size) { @@ -1771,7 +1787,8 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index) if (start_index < cache->block_start_index) { /* Add (request) needed entries before already cached ones. */ - /* Note: We need some index black magic to wrap around (cycle) inside our cache_size array... */ + /* Note: We need some index black magic to wrap around (cycle) + * inside our cache_size array... */ int size1 = cache->block_start_index - start_index; int size2 = 0; int idx1, idx2; @@ -1802,7 +1819,8 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index) // printf("\tstart-extended...\n"); if (end_index > cache->block_end_index) { /* Add (request) needed entries after already cached ones. */ - /* Note: We need some index black magic to wrap around (cycle) inside our cache_size array... */ + /* Note: We need some index black magic to wrap around (cycle) + * inside our cache_size array... */ int size1 = end_index - cache->block_end_index; int size2 = 0; int idx1, idx2; @@ -1899,11 +1917,13 @@ bool filelist_cache_previews_update(FileList *filelist) FileListEntryPreview *preview = BLI_thread_queue_pop(cache->previews_done); FileDirEntry *entry; - /* Paranoid (should never happen currently since we consume this queue from a single thread), but... */ + /* Paranoid (should never happen currently + * since we consume this queue from a single thread), but... */ if (!preview) { continue; } - /* entry might have been removed from cache in the mean time, we do not want to cache it again here. */ + /* entry might have been removed from cache in the mean time, + * we do not want to cache it again here. */ entry = filelist_file_ex(filelist, preview->index, false); // printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img); @@ -1921,7 +1941,8 @@ bool filelist_cache_previews_update(FileList *filelist) } else if (entry) { /* We want to avoid re-processing this entry continuously! - * Note that, since entries only live in cache, preview will be retried quite often anyway. */ + * Note that, since entries only live in cache, + * preview will be retried quite often anyway. */ entry->flags |= FILE_ENTRY_INVALID_PREVIEW; } @@ -1964,7 +1985,8 @@ static bool file_is_blend_backup(const char *str) return (retval); } -/* TODO: Maybe we should move this to BLI? On the other hand, it's using defines from spacefile area, so not sure... */ +/* TODO: Maybe we should move this to BLI? + * On the other hand, it's using defines from spacefile area, so not sure... */ int ED_path_extension_type(const char *path) { if (BLO_has_bfile_extension(path)) { @@ -2268,7 +2290,8 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const return nbr_entries; } - /* memory for strings is passed into filelist[i].entry->relpath and freed in filelist_entry_free. */ + /* memory for strings is passed into filelist[i].entry->relpath + * and freed in filelist_entry_free. */ if (group) { idcode = groupname_to_code(group); names = BLO_blendhandle_get_datablock_names(libfiledata, idcode, &nnames); @@ -2311,7 +2334,8 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const } #if 0 -/* Kept for reference here, in case we want to add back that feature later. We do not need it currently. */ +/* Kept for reference here, in case we want to add back that feature later. + * We do not need it currently. */ /* Code ***NOT*** updated for job stuff! */ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist) { @@ -2385,7 +2409,8 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist) } } - /* XXX TODO: if databrowse F4 or append/link filelist->flags & FLF_HIDE_PARENT has to be set */ + /* XXX TODO: if databrowse F4 or append/link + * filelist->flags & FLF_HIDE_PARENT has to be set */ if (!(filelist->filter_data.flags & FLF_HIDE_PARENT)) filelist->filelist.nbr_entries++; @@ -2499,10 +2524,11 @@ static void filelist_readjob_do( BLI_stack_discard(todo_dirs); - /* ARRRG! We have to be very careful *not to use* common BLI_path_util helpers over entry->relpath itself - * (nor any path containing it), since it may actually be a datablock name inside .blend file, - * which can have slashes and backslashes! See T46827. - * Note that in the end, this means we 'cache' valid relative subdir once here, this is actually better. */ + /* ARRRG! We have to be very careful *not to use* common BLI_path_util helpers over + * entry->relpath itself (nor any path containing it), since it may actually be a datablock + * name inside .blend file, which can have slashes and backslashes! See T46827. + * Note that in the end, this means we 'cache' valid relative subdir once here, + * this is actually better. */ BLI_strncpy(rel_subdir, subdir, sizeof(rel_subdir)); BLI_cleanup_dir(root, rel_subdir); BLI_path_rel(rel_subdir, root); @@ -2521,13 +2547,15 @@ static void filelist_readjob_do( /* Generate our entry uuid. Abusing uuid as an uint32, shall be more than enough here, * things would crash way before we overflow that counter! * Using an atomic operation to avoid having to lock thread... - * Note that we do not really need this here currently, since there is a single listing thread, but better + * Note that we do not really need this here currently, + * since there is a single listing thread, but better * remain consistent about threading! */ *((uint32_t *)entry->uuid) = atomic_add_and_fetch_uint32((uint32_t *)filelist->filelist_intern.curr_uuid, 1); /* Only thing we change in direntry here, so we need to free it first. */ MEM_freeN(entry->relpath); - entry->relpath = BLI_strdup(dir + 2); /* + 2 to remove '//' added by BLI_path_rel to rel_subdir */ + entry->relpath = BLI_strdup(dir + 2); /* + 2 to remove '//' + * added by BLI_path_rel to rel_subdir */ entry->name = BLI_strdup(fileentry_uiname(root, entry->relpath, entry->typeflag, dir)); /* Here we decide whether current filedirentry is to be listed too, or not. */ @@ -2568,7 +2596,8 @@ static void filelist_readjob_do( MEM_freeN(subdir); } - /* If we were interrupted by stop, stack may not be empty and we need to free pending dir paths. */ + /* If we were interrupted by stop, stack may not be empty and we need to free + * pending dir paths. */ while (!BLI_stack_is_empty(todo_dirs)) { td_dir = BLI_stack_peek(todo_dirs); MEM_freeN(td_dir->dir); @@ -2601,7 +2630,8 @@ typedef struct FileListReadJob { ThreadMutex lock; char main_name[FILE_MAX]; struct FileList *filelist; - struct FileList *tmp_filelist; /* XXX We may use a simpler struct here... just a linked list and root path? */ + /** XXX We may use a simpler struct here... just a linked list and root path? */ + struct FileList *tmp_filelist; } FileListReadJob; static void filelist_readjob_startjob(void *flrjv, short *stop, short *do_update, float *progress) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index cb014f30d95..f25d3e25f0b 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -627,7 +627,8 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche */ for (i = 0; i < n; i++) { file = filelist_file(sfile->files, i); - /* Do not check whether file is a file or dir here! Causes T44243 (we do accept dirs at this stage). */ + /* Do not check whether file is a file or dir here! Causes T44243 + * (we do accept dirs at this stage). */ if (fnmatch(pattern, file->relpath, 0) == 0) { filelist_entry_select_set(sfile->files, file, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); if (!match) { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 2fa9134165d..e18d4fe991e 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -512,7 +512,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) { /* Get mounted volumes better method OSX 10.6 and higher, see: */ /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ - /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */ + + /* we get all volumes sorted including network and do not relay + * on user-defined finder visibility, less confusing */ CFURLRef cfURL = NULL; CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; @@ -646,7 +648,8 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) * Assuming every entry ends with the share name */ const char *label = strstr(dirname, "share="); if (label != NULL) { - /* Move pointer so "share=" is trimmed off or use full dirname as label. */ + /* Move pointer so "share=" is trimmed off + * or use full dirname as label. */ const char *label_test = label + 6; label = *label_test ? label_test : dirname; } -- cgit v1.2.3