Skip to content

Commit

Permalink
Fix #4575: Readable Editor GUI Selector doesn't accept selection
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 18, 2017
1 parent b80c162 commit 8ff4c60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions plugins/dm.gui/GuiSelector.cpp
Expand Up @@ -54,6 +54,17 @@ GuiSelector::GuiSelector(bool twoSided, ReadableEditorDialog* editorDialog) :
FindWindowById(wxID_OK, this)->Enable(false);
}

bool GuiSelector::Destroy()
{
// Prevent the page switch event from firing after window destruction
// In wxGTK the window might not be destroyed right away (only later in an idle event)
// which will trigger page switch events and inadvertently change our GUI selection.
_notebook->Disconnect(wxEVT_NOTEBOOK_PAGE_CHANGED,
wxBookCtrlEventHandler(GuiSelector::onPageSwitch), NULL, this);

return wxutil::DialogBase::Destroy();
}

std::string GuiSelector::Run(bool twoSided, ReadableEditorDialog* editorDialog)
{
GuiSelector* dialog = new GuiSelector(twoSided, editorDialog);
Expand Down
3 changes: 3 additions & 0 deletions plugins/dm.gui/GuiSelector.h
Expand Up @@ -65,6 +65,9 @@ class GuiSelector :
void visit(wxutil::TreeModel& store, wxutil::TreeModel::Row& row,
const std::string& path, bool isExplicit);

// Disconnect all events when the dialog is destroyed
virtual bool Destroy() override;

private:
GuiSelector(bool twoSided, ReadableEditorDialog* editorDialog);

Expand Down

0 comments on commit 8ff4c60

Please sign in to comment.