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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions common/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@
#include "../common/utilities/string/trim-newlines.h"
#include "../common/utilities/imgui/wrap.h"


namespace rs2
{
template <typename T>
T non_negative(const T& input)
{
return std::max(static_cast<T>(0), input);
}

// Allocates a frameset from points and texture frames
frameset_allocator::frameset_allocator(viewer_model* viewer) : owner(viewer),
filter([this](frame f, frame_source& s)
Expand Down Expand Up @@ -1392,9 +1399,6 @@ namespace rs2
error_message = ex.what();
}




window.begin_viewport();

auto flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove
Expand All @@ -1410,11 +1414,23 @@ namespace rs2

ImGui::Begin("Viewport", nullptr, { viewer_rect.w, viewer_rect.h }, 0.f, flags);

draw_viewport(viewer_rect, window, devices, error_message, texture_frame, p);
try
{
draw_viewport( viewer_rect, window, devices, error_message, texture_frame, p );

modal_notification_on = not_model->draw(window,
static_cast<int>(window.width()), static_cast<int>(window.height()),
error_message);
modal_notification_on = not_model->draw( window,
static_cast< int >( window.width() ),
static_cast< int >( window.height() ),
error_message );
}
catch( const error & e )
{
error_message = error_to_string( e );
}
catch( const std::exception & e )
{
error_message = e.what();
}

popup_if_error(window, error_message);

Expand Down Expand Up @@ -1930,8 +1946,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>(non_negative(viewer_rect.x)), static_cast<GLint>(non_negative(bottom_y)),
static_cast<GLsizei>(non_negative(viewer_rect.w)), static_cast<GLsizei>(non_negative(viewer_rect.h - top_bar_height)));

glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Expand All @@ -1940,7 +1956,7 @@ namespace rs2

glMatrixMode(GL_PROJECTION);
glPushMatrix();
gluPerspective(45, viewer_rect.w / win.framebuf_height(), 0.001f, 100.0f);
gluPerspective(45, non_negative(viewer_rect.w / win.framebuf_height()), 0.001f, 100.0f);
matrix4 perspective_mat;
glGetFloatv(GL_PROJECTION_MATRIX, perspective_mat);
glPopMatrix();
Expand Down
23 changes: 22 additions & 1 deletion tools/depth-quality/depth-quality-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,28 @@ namespace rs2
if (dpt)
_metrics_model.begin_process_frame(dpt);
}
catch (...){} // on device disconnect
catch( const error & e )
{
// Can occur on device disconnect
_viewer_model.not_model->output.add_log( RS2_LOG_SEVERITY_DEBUG,
__FILE__,
__LINE__,
error_to_string( e ) );
}
catch( const std::exception & e )
{
_viewer_model.not_model->output.add_log( RS2_LOG_SEVERITY_ERROR,
__FILE__,
__LINE__,
e.what() );
}
catch( ... )
{
_viewer_model.not_model->output.add_log( RS2_LOG_SEVERITY_ERROR,
__FILE__,
__LINE__,
"Unknown error occurred" );
}

}

Expand Down