Skip to content
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

Merged
merged 2 commits into from Mar 30, 2021

Conversation

Nir-Az
Copy link
Collaborator

@Nir-Az Nir-Az commented Mar 29, 2021

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]

Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactoring requested

@@ -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
Copy link
Collaborator

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)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, Done

@@ -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)),
Copy link
Collaborator

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

Copy link
Collaborator Author

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

@maloel maloel merged commit 504ac4a into IntelRealSense:development Mar 30, 2021
@Nir-Az Nir-Az deleted the fix_debug_opengl_crash branch April 8, 2021 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants