Skip to content

Fix DQT + Viewer crash when minimized when running on Debug - #8693

Merged
maloel merged 2 commits into
realsenseai:developmentfrom
Nir-Az:fix_debug_opengl_crash
Mar 30, 2021
Merged

Fix DQT + Viewer crash when minimized when running on Debug#8693
maloel merged 2 commits into
realsenseai:developmentfrom
Nir-Az:fix_debug_opengl_crash

Conversation

@Nir-Az

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

Copy link
Copy Markdown
Collaborator

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]

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small refactoring requested

Comment thread common/viewer.cpp Outdated
#include "../common/utilities/string/trim-newlines.h"
#include "../common/utilities/imgui/wrap.h"

#define FORCE_NON_NEGATIVE(input) input < 0 ? 0 : input

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Comment thread common/viewer.cpp Outdated

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
Copy Markdown
Contributor

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
Copy Markdown
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 realsenseai: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.

3 participants