cocoadisplay: fix unprotected debug/spam prints

This commit is contained in:
rdb 2022-12-07 17:20:41 +01:00
parent 2a65f583d0
commit c85cc8f2e8

View File

@ -230,8 +230,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
_context_needs_update = true;
[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.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) {
[_window setFrame:[_window frameRectForContentRect:frame] display:NO];
@ -1739,16 +1744,20 @@ handle_close_request() {
// and process it directly.
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.
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.
return true;
@ -1759,7 +1768,9 @@ handle_close_request() {
*/
void CocoaGraphicsWindow::
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;
@ -1995,15 +2006,19 @@ handle_mouse_button_event(int button, bool down) {
_input->button_down(MouseButton::button(button));
#ifndef NDEBUG
cocoadisplay_cat.spam()
<< "Mouse button " << button << " down\n";
if (cocoadisplay_cat.is_spam()) {
cocoadisplay_cat.spam()
<< "Mouse button " << button << " down\n";
}
#endif
} else {
_input->button_up(MouseButton::button(button));
#ifndef NDEBUG
cocoadisplay_cat.spam()
<< "Mouse button " << button << " up\n";
if (cocoadisplay_cat.is_spam()) {
cocoadisplay_cat.spam()
<< "Mouse button " << button << " up\n";
}
#endif
}
}