Skip to content
Snippets Groups Projects
Commit 677cb864 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

remove function pointer initialization

... to have a std::bad_function_call exception in case of an uninitialized function pointer
parent 7f8a7f0c
No related branches found
No related tags found
1 merge request!393Selection descriptor
Pipeline #46904 passed
......@@ -40,25 +40,14 @@ using std::function;
//! member, a std::variant or any other construction to define a selection.
template <typename T> class SelectionDescriptor {
public:
SelectionDescriptor()
{
// initialize function pointers to a lambda which throws an error. This helps later on if
// accidentally the real initialization has been forgotten.
setCurrentIndex = [](int) { throw std::runtime_error("Function pointer not initialized"); };
currentIndex = []() -> int {
throw std::runtime_error("Function pointer not initialized");
};
currentItem = []() -> T { throw std::runtime_error("Function pointer not initialized"); };
}
SelectionDescriptor() = default;
//! Initialize the members by means of a GroupItem.
//!
//! currentItem can only be initialized if the template parameter is a pointer (like
//! RotationItem*). If it is e.g. a std::variant<>, the currentItem has to be initialized by the
//! caller. Only for easier migration. Should be removed after SessionItem refactoring.
explicit SelectionDescriptor(GroupItem* item) : SelectionDescriptor()
explicit SelectionDescriptor(GroupItem* item)
{
label = item->displayName();
options = item->value().value<ComboProperty>().getValues();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment