Skip to content

Commit

Permalink
Add "Find:" label to search popup. Fix a crash during shutdown due to…
Browse files Browse the repository at this point in the history
… an internal pointer in the wxMSW implementation not being cleared, so call Hide() before Destroy().
  • Loading branch information
codereader committed Dec 27, 2019
1 parent a1f6740 commit bcb2889
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libs/wxutil/TreeView.cpp
Expand Up @@ -5,6 +5,7 @@

#include <wx/bmpbuttn.h>
#include <wx/popupwin.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/timer.h>
#include <wx/artprov.h>
Expand Down Expand Up @@ -208,12 +209,14 @@ class TreeView::SearchPopupWindow :

public:
SearchPopupWindow(TreeView* treeView, Search& owner) :
wxPopupWindow(treeView),
wxPopupWindow(treeView, wxBORDER_SIMPLE),
_owner(owner),
_entry(nullptr)
{
SetSizer(new wxBoxSizer(wxHORIZONTAL));

auto label = new wxStaticText(this, wxID_ANY, _("Find: "));

_entry = new wxTextCtrl(this, wxID_ANY);

auto nextImg = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "arrow_down.png");
Expand All @@ -231,6 +234,7 @@ class TreeView::SearchPopupWindow :
nextButton->Bind(wxEVT_BUTTON, [this] (wxCommandEvent& ev) { _owner.HighlightNextMatch(); });
prevButton->Bind(wxEVT_BUTTON, [this] (wxCommandEvent& ev) { _owner.HighlightPrevMatch(); });

GetSizer()->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);
GetSizer()->Add(_entry, 1, wxEXPAND | wxALL, 6);
GetSizer()->Add(prevButton, 0, wxEXPAND | wxRIGHT | wxTOP | wxBOTTOM, 6);
GetSizer()->Add(nextButton, 0, wxEXPAND | wxRIGHT | wxTOP | wxBOTTOM, 6);
Expand Down Expand Up @@ -269,6 +273,11 @@ TreeView::Search::Search(TreeView& treeView) :

TreeView::Search::~Search()
{
_closeTimer.Stop();

// Always hide popup windows before destroying them, otherwise the
// wx-internal wxCurrentPopupWindow pointer doesn't get cleared (in MSW at least)
_popup->Hide();
_popup->Destroy();
_popup = nullptr;
_curSearchMatch = wxDataViewItem();
Expand Down

0 comments on commit bcb2889

Please sign in to comment.