Skip to content

Commit

Permalink
PR IntelRealSense#32 from Nir: Fix viewer crash when trigger CAH in h…
Browse files Browse the repository at this point in the history
…igh temperature
  • Loading branch information
maloel authored Jul 20, 2020
2 parents 6d89734 + 243d2f9 commit 2043b65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
27 changes: 22 additions & 5 deletions common/cah-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define GLFW_INCLUDE_NONE
#include "fw-update-helper.h"
#include "model-views.h"

using namespace rs2;

// This variable is global for protecting the case when the callback will be called when the device model no longer exist.
Expand All @@ -31,7 +31,7 @@ cah_model::cah_model(device_model & dev_model, viewer_model& viewer) :
}


bool cah_model::prompt_trigger_popup(ux_window& window, const std::string& error_message)
bool cah_model::prompt_trigger_popup(ux_window& window, std::string& error_message)
{
// This process is built from a 2 stages windows, first a yes/no window and then a process window
bool keep_showing = true;
Expand Down Expand Up @@ -93,7 +93,17 @@ bool cah_model::prompt_trigger_popup(ux_window& window, const std::string& error
{
auto sd = *itr;
global_calib_status = RS2_CALIBRATION_RETRY; // To indicate in progress state
sd->s->set_option(RS2_OPTION_TRIGGER_CAMERA_ACCURACY_HEALTH, 1.0f);
try
{
sd->s->set_option(RS2_OPTION_TRIGGER_CAMERA_ACCURACY_HEALTH, static_cast<float>(RS2_CAH_TRIGGER_NOW));
}
catch (std::exception const & e)
{
error_message = to_string() << "Trigger calibration failure:\n" << e.what();
_process_started = false;
global_calib_status = RS2_CALIBRATION_FAILED;
return false;
}

_state = model_state_type::PROCESS_MODAL;
// We switch to process state without a guarantee that the process really started,
Expand Down Expand Up @@ -164,7 +174,7 @@ bool cah_model::prompt_trigger_popup(ux_window& window, const std::string& error
return keep_showing;
}

bool cah_model::prompt_reset_popup(ux_window& window, const std::string& error_message)
bool cah_model::prompt_reset_popup(ux_window& window, std::string& error_message)
{
bool keep_showing = true;
bool yes_was_chosen = false;
Expand All @@ -186,7 +196,14 @@ bool cah_model::prompt_reset_popup(ux_window& window, const std::string& error_m
{
auto sd = *itr;
// Trigger CAH process
sd->s->set_option(RS2_OPTION_RESET_CAMERA_ACCURACY_HEALTH, 1.0f);
try
{
sd->s->set_option(RS2_OPTION_RESET_CAMERA_ACCURACY_HEALTH, 1.0f);
}
catch (std::exception const & e)
{
error_message = to_string() << "Calibration reset failure:\n" << e.what();
}
}
}
keep_showing = false;
Expand Down
4 changes: 2 additions & 2 deletions common/cah-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ namespace rs2
public:
cah_model(device_model & dev_model, viewer_model& viewer);

bool prompt_trigger_popup(ux_window& window, const std::string& error_message);
bool prompt_reset_popup(ux_window& window, const std::string& error_message);
bool prompt_trigger_popup(ux_window& window, std::string& error_message);
bool prompt_reset_popup(ux_window& window, std::string& error_message);
private:

device_model & _dev_model;
Expand Down

0 comments on commit 2043b65

Please sign in to comment.