-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DQT + Viewer crash when minimized when running on Debug #8693
Fix DQT + Viewer crash when minimized when running on Debug #8693
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small refactoring requested
common/viewer.cpp
Outdated
@@ -24,6 +24,8 @@ | |||
#include "../common/utilities/string/trim-newlines.h" | |||
#include "../common/utilities/imgui/wrap.h" | |||
|
|||
#define FORCE_NON_NEGATIVE(input) input < 0 ? 0 : input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the macro with inline, e.g.
template<typename T>
T non_negative(const T& input)
{
return std::max(0, input)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, Done
common/viewer.cpp
Outdated
@@ -1930,8 +1941,8 @@ namespace rs2 | |||
|
|||
auto bottom_y = win.framebuf_height() - viewer_rect.y - viewer_rect.h; | |||
|
|||
glViewport(static_cast<GLint>(viewer_rect.x), static_cast<GLint>(bottom_y), | |||
static_cast<GLsizei>(viewer_rect.w), static_cast<GLsizei>(viewer_rect.h - top_bar_height)); | |||
glViewport(static_cast<GLint>(FORCE_NON_NEGATIVE(viewer_rect.x)), static_cast<GLint>(FORCE_NON_NEGATIVE(bottom_y)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above refactor may save the explicit casts and make it more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need the explicit cast , otherwise we get a warning
When running on Debug configuration, minimizing the DQT / Viewer windows cause the application to crash.
On this PR I add protection against illegal inputs to open-gl functions
Tracked on [RS5-10796]