diff --git a/src/display_wallet.cpp b/src/display_wallet.cpp index 5f0ac60..b1dbacf 100644 --- a/src/display_wallet.cpp +++ b/src/display_wallet.cpp @@ -9,7 +9,7 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : m_read_from_misc(m_db), m_insert_name(m_db), m_find_position(m_db, R"|( SELECT COUNT(*) FROM UserZookoIDs -WHERE LOWER("name")GetSizer()), + dirty_area(sizer->ComputeFittingClientSize(singletonFrame)) + { + assert(sizer); + } + ~cleanup() { + auto desired_size = sizer->ComputeFittingClientSize(singletonFrame); + dirty_area.IncTo(desired_size); + //singletonFrame->SetMinClientSize(desired_size); + auto clientSize = singletonFrame->GetClientSize(); + desired_size.IncTo(clientSize); + if (desired_size.GetHeight() > clientSize.GetHeight() + || desired_size.GetWidth() > clientSize.GetWidth() + )singletonFrame->SetClientSize(desired_size); + } +}; + void display_wallet::add_name_event_handler(wxCommandEvent& event) { wxTextEntryDialog dialog(this, R"("A Zooko name has a human readable name, @@ -76,13 +109,8 @@ and a public key defined by the name and the wallet master secret)", pubkey ); m_find_position.read_one(zookoNickname_psz); - auto sizer = this->GetSizer(); - auto dirty_area = sizer->ComputeFittingClientSize(singletonFrame); - auto m_lsizer = sizer->GetItem((size_t)0)->GetSizer(); - assert(m_lsizer); - auto m_rsizer = sizer->GetItem(1)->GetSizer(); - assert(m_rsizer); auto position = m_find_position.column(0); + cleanup cln(this); m_lSizer->Insert(position, new wxStaticText( this, @@ -103,15 +131,6 @@ and a public key defined by the name and the wallet master secret)", 10, wxALL, // and make border all around 2); - - auto desired_size = sizer->ComputeFittingClientSize(singletonFrame); - dirty_area.IncTo(desired_size); - //singletonFrame->SetMinClientSize(desired_size); - auto clientSize = singletonFrame->GetClientSize(); - desired_size.IncTo(clientSize); - if (desired_size.GetHeight() > clientSize.GetHeight() - || desired_size.GetWidth() > clientSize.GetWidth() - )singletonFrame->SetClientSize(desired_size); } } @@ -129,14 +148,7 @@ void display_wallet::OnClose(wxCloseEvent& event) { } void display_wallet::refresh_from_database() { - auto sizer = this->GetSizer(); - auto dirty_area = sizer->ComputeFittingClientSize(singletonFrame); - auto m_lsizer = sizer->GetItem((size_t)0)->GetSizer(); - assert(m_lsizer); - auto m_rsizer = sizer->GetItem(1)->GetSizer(); - assert(m_rsizer); - m_lsizer->Clear(true); - m_rsizer->Clear(true); + cleanup cln(this); try { m_read_names_and_keys.reset(); while (m_read_names_and_keys.step() == Icompiled_sql::ROW) { @@ -177,12 +189,4 @@ void display_wallet::refresh_from_database() { szError = sz_unknown_error; throw MyException(sz_unknown_error, __LINE__, __func__, SrcFilename); } - auto desired_size = sizer->ComputeFittingClientSize(singletonFrame); - dirty_area.IncTo(desired_size); - //singletonFrame->SetMinClientSize(desired_size); - auto clientSize = singletonFrame->GetClientSize(); - desired_size.IncTo(clientSize); - if (desired_size.GetHeight() > clientSize.GetHeight() - || desired_size.GetWidth() > clientSize.GetWidth() - )singletonFrame->SetClientSize(desired_size); } diff --git a/src/display_wallet.h b/src/display_wallet.h index 5328328..7290518 100644 --- a/src/display_wallet.h +++ b/src/display_wallet.h @@ -5,6 +5,7 @@ public: display_wallet(wxWindow*, wxFileName&); ~display_wallet(); private: + struct cleanup; typedef MenuLink MenuLink; ro::dbconnect m_db; sql_read_from_misc m_read_from_misc;