Fix crash if you cancel the scenario selection
This commit is contained in:
@@ -114,11 +114,22 @@ public:
|
||||
void run(std::function<void(cDialog&)> onopen = nullptr); // cd_run_dialog
|
||||
/// Get the result of the dialog.
|
||||
/// @tparam type The result type.
|
||||
/// @throw boost::bad_any_cast if the provided result type is different from the type set by getResult().
|
||||
/// @throw boost::bad_any_cast if the provided result type is different from the type set by setResult().
|
||||
/// @return The dialog's result.
|
||||
template<typename type> type getResult() const {
|
||||
return boost::any_cast<type>(result);
|
||||
}
|
||||
/// Check if the dialog has a result.
|
||||
/// @return true if setResult() was called, otherwise false.
|
||||
bool hasResult() const {
|
||||
return !result.empty();
|
||||
}
|
||||
/// Query the type of the result.
|
||||
/// @tparam type The result type to query.
|
||||
/// @return true if the type matches that set by setResult().
|
||||
template<typename type> bool resultIs() const {
|
||||
return result.type() == typeid(type);
|
||||
}
|
||||
/// Set the result of the dialog.
|
||||
/// @tparam type The result type.
|
||||
/// @param val The result value.
|
||||
|
@@ -1508,8 +1508,6 @@ class cChooseScenario {
|
||||
}
|
||||
|
||||
bool doCancel() {
|
||||
scen_header_type null;
|
||||
me.setResult<scen_header_type>(null);
|
||||
me.toast(false);
|
||||
return true;
|
||||
}
|
||||
@@ -1576,6 +1574,7 @@ public:
|
||||
}
|
||||
|
||||
me.run();
|
||||
if(!me.hasResult()) return scen_header_type{};
|
||||
scen_header_type scen = me.getResult<scen_header_type>();
|
||||
if(scen.file.empty()){
|
||||
std::ostringstream error;
|
||||
|
Reference in New Issue
Block a user