[Bf-blender-cvs] [3e4863376e4] master: Cleanup: use boolean for has_event variable & return value

Campbell Barton noreply at git.blender.org
Mon May 3 16:18:57 CEST 2021


Commit: 3e4863376e47763a1396921977c7277c631d8dff
Author: Campbell Barton
Date:   Tue May 4 00:14:05 2021 +1000
Branches: master
https://developer.blender.org/rB3e4863376e47763a1396921977c7277c631d8dff

Cleanup: use boolean for has_event variable & return value

===================================================================

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/test/gears/GHOST_C-Test.c
M	intern/ghost/test/multitest/MultiTest.c
M	source/blender/windowmanager/intern/wm_playanim.c
M	source/blender/windowmanager/intern/wm_window.c

===================================================================

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index d79111b742f..c776eb6b44c 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -276,7 +276,7 @@ extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle);
  * wait (block) until the next event before returning.
  * \return Indication of the presence of events.
  */
-extern int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent);
+extern bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent);
 
 /**
  * Retrieves events from the queue and send them to the event consumers.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index af65e1cd4d2..1d96354c504 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -248,11 +248,11 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
   return (int)system->getFullScreen();
 }
 
-int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
+bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent)
 {
   GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
 
-  return (int)system->processEvents(waitForEvent ? true : false);
+  return system->processEvents(waitForEvent);
 }
 
 void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c
index 4283f990cfb..8cd1b5acb89 100644
--- a/intern/ghost/test/gears/GHOST_C-Test.c
+++ b/intern/ghost/test/gears/GHOST_C-Test.c
@@ -477,7 +477,7 @@ int main(int argc, char **argv)
 
     /* Enter main loop */
     while (!sExitRequested) {
-      if (!GHOST_ProcessEvents(shSystem, 0)) {
+      if (!GHOST_ProcessEvents(shSystem, false)) {
 #ifdef WIN32
         /* If there were no events, be nice to other applications */
         Sleep(10);
diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c
index 8c8858fc6d8..3b424f1ca89 100644
--- a/intern/ghost/test/multitest/MultiTest.c
+++ b/intern/ghost/test/multitest/MultiTest.c
@@ -926,7 +926,7 @@ void multitestapp_exit(MultiTestApp *app)
 void multitestapp_run(MultiTestApp *app)
 {
   while (!app->exit) {
-    GHOST_ProcessEvents(app->sys, 1);
+    GHOST_ProcessEvents(app->sys, true);
     GHOST_DispatchEvents(app->sys);
   }
 }
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 58030920fc7..d33948c97d5 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -441,7 +441,7 @@ static void build_pict_list_ex(
      */
 
     while (IMB_ispic(filepath) && totframes) {
-      bool hasevent;
+      bool has_event;
       size_t size;
       int file;
 
@@ -522,7 +522,7 @@ static void build_pict_list_ex(
       BLI_path_sequence_encode(
           filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
 
-      while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
+      while ((has_event = GHOST_ProcessEvents(g_WS.ghost_system, false))) {
         GHOST_DispatchEvents(g_WS.ghost_system);
         if (ps->loading == false) {
           return;
@@ -1389,7 +1389,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
 #endif
 
     while (ps.picture) {
-      int hasevent;
+      bool has_event;
 #ifndef USE_IMB_CACHE
       if (ibuf != NULL && ibuf->ftype == IMB_FTYPE_NONE) {
         IMB_freeImBuf(ibuf);
@@ -1474,14 +1474,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
 
       ps.next_frame = ps.direction;
 
-      while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
+      while ((has_event = GHOST_ProcessEvents(g_WS.ghost_system, false))) {
         GHOST_DispatchEvents(g_WS.ghost_system);
       }
       if (ps.go == false) {
         break;
       }
       change_frame(&ps);
-      if (!hasevent) {
+      if (!has_event) {
         PIL_sleep_ms(1);
       }
       if (ps.wait2) {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 2e9fd1b1b16..b90352b9e62 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -133,7 +133,7 @@ static struct WMInitStruct {
  * \{ */
 
 static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate);
-static int wm_window_timer(const bContext *C);
+static bool wm_window_timer(const bContext *C);
 
 /* XXX this one should correctly check for apple top header...
  * done for Cocoa : returns window contents (and not frame) max size*/
@@ -1498,12 +1498,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
  * Timer handlers should check for delta to decide if they just update, or follow real time.
  * Timer handlers can also set duration to match frames passed
  */
-static int wm_window_timer(const bContext *C)
+static bool wm_window_timer(const bContext *C)
 {
   Main *bmain = CTX_data_main(C);
   wmWindowManager *wm = CTX_wm_manager(C);
   double time = PIL_check_seconds_timer();
-  int retval = 0;
+  bool has_event = false;
 
   /* Mutable in case the timer gets removed. */
   LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
@@ -1540,31 +1540,31 @@ static int wm_window_timer(const bContext *C)
         event.customdata = wt;
         wm_event_add(win, &event);
 
-        retval = 1;
+        has_event = true;
       }
     }
   }
-  return retval;
+  return has_event;
 }
 
 void wm_window_process_events(const bContext *C)
 {
   BLI_assert(BLI_thread_is_main());
 
-  int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
+  bool has_event = GHOST_ProcessEvents(g_system, false); /* `false` is no wait. */
 
-  if (hasevent) {
+  if (has_event) {
     GHOST_DispatchEvents(g_system);
   }
-  hasevent |= wm_window_timer(C);
+  has_event |= wm_window_timer(C);
 #ifdef WITH_XR_OPENXR
   /* XR events don't use the regular window queues. So here we don't only trigger
    * processing/dispatching but also handling. */
-  hasevent |= wm_xr_events_handle(CTX_wm_manager(C));
+  has_event |= wm_xr_events_handle(CTX_wm_manager(C));
 #endif
 
   /* no event, we sleep 5 milliseconds */
-  if (hasevent == 0) {
+  if (has_event == false) {
     PIL_sleep_ms(5);
   }
 }



More information about the Bf-blender-cvs mailing list