Browse Source

cocoadisplay: fix unprotected debug/spam prints

rdb 3 years ago
parent
commit
c85cc8f2e8
1 changed files with 29 additions and 14 deletions
  1. 29 14
      panda/src/cocoadisplay/cocoaGraphicsWindow.mm

+ 29 - 14
panda/src/cocoadisplay/cocoaGraphicsWindow.mm

@@ -230,8 +230,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
       _context_needs_update = true;
       _context_needs_update = true;
       [cocoagsg->_context setView:_view];
       [cocoagsg->_context setView:_view];
 
 
-      cocoadisplay_cat.spam()
-        << "Switching context to view " << _view << "\n";
+      if (cocoadisplay_cat.is_spam()) {
+        cocoadisplay_cat.spam()
+          << "Switching context to view " << _view << "\n";
+      }
     }
     }
   }
   }
 
 
@@ -1070,8 +1072,11 @@ set_properties_now(WindowProperties &properties) {
       frame.origin.x = x;
       frame.origin.x = x;
       frame.origin.y = container.size.height - y - frame.size.height;
       frame.origin.y = container.size.height - y - frame.size.height;
 
 
-      cocoadisplay_cat.debug()
-        << "Setting window content origin to " << frame.origin.x << ", " << frame.origin.y << "\n";
+      if (cocoadisplay_cat.is_debug()) {
+        cocoadisplay_cat.debug()
+          << "Setting window content origin to "
+          << frame.origin.x << ", " << frame.origin.y << "\n";
+      }
 
 
       if (_window != nil) {
       if (_window != nil) {
         [_window setFrame:[_window frameRectForContentRect:frame] display:NO];
         [_window setFrame:[_window frameRectForContentRect:frame] display:NO];
@@ -1739,16 +1744,20 @@ handle_close_request() {
     // and process it directly.
     // and process it directly.
     throw_event(close_request_event);
     throw_event(close_request_event);
 
 
-    cocoadisplay_cat.debug()
-      << "Window requested close.  Rejecting, throwing event "
-      << close_request_event << " instead\n";
+    if (cocoadisplay_cat.is_debug()) {
+      cocoadisplay_cat.debug()
+        << "Window requested close.  Rejecting, throwing event "
+        << close_request_event << " instead\n";
+    }
 
 
     // Prevent the operating system from closing the window.
     // Prevent the operating system from closing the window.
     return false;
     return false;
   }
   }
 
 
-  cocoadisplay_cat.debug()
-    << "Window requested close, accepting\n";
+  if (cocoadisplay_cat.is_debug()) {
+    cocoadisplay_cat.debug()
+      << "Window requested close, accepting\n";
+  }
 
 
   // Let the operating system close the window normally.
   // Let the operating system close the window normally.
   return true;
   return true;
@@ -1759,7 +1768,9 @@ handle_close_request() {
  */
  */
 void CocoaGraphicsWindow::
 void CocoaGraphicsWindow::
 handle_close_event() {
 handle_close_event() {
-  cocoadisplay_cat.debug() << "Window is about to close\n";
+  if (cocoadisplay_cat.is_debug()) {
+    cocoadisplay_cat.debug() << "Window is about to close\n";
+  }
 
 
   _window = nil;
   _window = nil;
 
 
@@ -1995,15 +2006,19 @@ handle_mouse_button_event(int button, bool down) {
     _input->button_down(MouseButton::button(button));
     _input->button_down(MouseButton::button(button));
 
 
 #ifndef NDEBUG
 #ifndef NDEBUG
-    cocoadisplay_cat.spam()
-      << "Mouse button " << button << " down\n";
+    if (cocoadisplay_cat.is_spam()) {
+      cocoadisplay_cat.spam()
+        << "Mouse button " << button << " down\n";
+    }
 #endif
 #endif
   } else {
   } else {
     _input->button_up(MouseButton::button(button));
     _input->button_up(MouseButton::button(button));
 
 
 #ifndef NDEBUG
 #ifndef NDEBUG
-    cocoadisplay_cat.spam()
-      << "Mouse button " << button << " up\n";
+    if (cocoadisplay_cat.is_spam()) {
+      cocoadisplay_cat.spam()
+        << "Mouse button " << button << " up\n";
+    }
 #endif
 #endif
   }
   }
 }
 }