Public Member Functions | |
| ActionGroupTrigger (FeHandle *editor, bool noRedraw) | |
| void | disable () |
| ~ActionGroupTrigger () | |
| fe::ActionGroupTrigger::ActionGroupTrigger | ( | FeHandle * | editor, | |
| bool | noRedraw | |||
| ) | [inline] |
Calls fe::IEditorFacade::openActionGroup() on the given editor.
| editor | handle to the target editor; | |
| noRedraw | value of the parameter for fe::IEditorFacade::openActionGroup() function to call on the target editor. |
| fe::ActionGroupTrigger::~ActionGroupTrigger | ( | ) | [inline] |
Calls fe::IEditorFacade::closeActionGroup() on the encapsulated editor if disable() has not been called.
As it is illegal to throw exceptions from destructor there is no way to propagate error that may occur in fe::IEditorFacade::closeActionGroup() call. Thus caller can't know if opened action group get closed. The workaround is to use fe::IEditorFacade::groupActionsCounter() to detect error:
void bar(fe::FeHandle* handle) { fe::ActionGroupTrigger group(handle, true /* noRedraw */); // ... } void foo(fe::FeHandle* handle) { fe::EditorFacadePeer editor(handle); // Remember current group counter value. const unsigned counter = editor.groupActionsCounter(); bar(handle); if(editor.groupActionsCounter() != counter) { // bar() failed to restore editor's action group counter, i.e. // ~ActionGroupTrigger() failed, so report error: throw std::runtime_error("~ActionGroupTrigger failed"); } }
| void fe::ActionGroupTrigger::disable | ( | ) | [inline] |
Instructs ~ActionGroupTrigger() not to call fe::IEditorFacade::closeActionGroup() on the encapsulated editor.