Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-08-19 04:46:29 +0300
committerHans Goudey <h.goudey@me.com>2020-08-19 04:47:00 +0300
commit349eebd7d1459fa2525850751040963899ef7535 (patch)
treeeb1db9c00555f8827fa3bd49afb744a1ada1ea6d /source/blender/editors/interface/interface_utils.c
parentffa8e7579916609b4ddd4dda031cf2a3a7eaefb1 (diff)
UI Code Quality: Use LISTBASE_FOREACH in interface directory
I only skipped a few loops in the monstrous ui_handle_menu_event function. Also, I only changed variable names where necessary to prevent redeclarations. Differential Revision: https://developer.blender.org/D8586
Diffstat (limited to 'source/blender/editors/interface/interface_utils.c')
-rw-r--r--source/blender/editors/interface/interface_utils.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 4a1c7be918e..f44987ac1d2 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -714,12 +714,8 @@ bool UI_butstore_is_valid(uiButStore *bs)
bool UI_butstore_is_registered(uiBlock *block, uiBut *but)
{
- uiButStore *bs_handle;
-
- for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
- uiButStoreElem *bs_elem;
-
- for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
+ LISTBASE_FOREACH (uiButStore *, bs_handle, &block->butstore) {
+ LISTBASE_FOREACH (uiButStoreElem *, bs_elem, &bs_handle->items) {
if (*bs_elem->but_p == but) {
return true;
}
@@ -740,10 +736,7 @@ void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p)
void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p)
{
- uiButStoreElem *bs_elem, *bs_elem_next;
-
- for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem_next) {
- bs_elem_next = bs_elem->next;
+ LISTBASE_FOREACH_MUTABLE (uiButStoreElem *, bs_elem, &bs_handle->items) {
if (bs_elem->but_p == but_p) {
BLI_remlink(&bs_handle->items, bs_elem);
MEM_freeN(bs_elem);
@@ -758,12 +751,10 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p)
*/
bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src)
{
- uiButStore *bs_handle;
bool found = false;
- for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
- uiButStoreElem *bs_elem;
- for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
+ LISTBASE_FOREACH (uiButStore *, bs_handle, &block->butstore) {
+ LISTBASE_FOREACH (uiButStoreElem *, bs_elem, &bs_handle->items) {
if (*bs_elem->but_p == but_src) {
*bs_elem->but_p = but_dst;
found = true;
@@ -779,14 +770,9 @@ bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *bu
*/
void UI_butstore_clear(uiBlock *block)
{
- uiButStore *bs_handle;
-
- for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
- uiButStoreElem *bs_elem;
-
+ LISTBASE_FOREACH (uiButStore *, bs_handle, &block->butstore) {
bs_handle->block = NULL;
-
- for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
+ LISTBASE_FOREACH (uiButStoreElem *, bs_elem, &bs_handle->items) {
*bs_elem->but_p = NULL;
}
}
@@ -797,8 +783,6 @@ void UI_butstore_clear(uiBlock *block)
*/
void UI_butstore_update(uiBlock *block)
{
- uiButStore *bs_handle;
-
/* move this list to the new block */
if (block->oldblock) {
if (block->oldblock->butstore.first) {
@@ -812,17 +796,14 @@ void UI_butstore_update(uiBlock *block)
/* warning, loop-in-loop, in practice we only store <10 buttons at a time,
* so this isn't going to be a problem, if that changes old-new mapping can be cached first */
- for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
-
+ LISTBASE_FOREACH (uiButStore *, bs_handle, &block->butstore) {
BLI_assert((bs_handle->block == NULL) || (bs_handle->block == block) ||
(block->oldblock && block->oldblock == bs_handle->block));
if (bs_handle->block == block->oldblock) {
- uiButStoreElem *bs_elem;
-
bs_handle->block = block;
- for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
+ LISTBASE_FOREACH (uiButStoreElem *, bs_elem, &bs_handle->items) {
if (*bs_elem->but_p) {
uiBut *but_new = ui_but_find_new(block, *bs_elem->but_p);