From a478a79e8b07d958ed5a976c0bad09ec30b4893f Mon Sep 17 00:00:00 2001 From: Cheng Date: Fri, 24 Feb 2023 11:33:09 +0800 Subject: [PATCH] handle exception while attempting to open an existing wallet --- src/frame.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/frame.cpp b/src/frame.cpp index 221b8fc..ad3731a 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -65,7 +65,7 @@ Frame::Frame(wxString wxs) m_panel(), m_LastUsedSqlite() { -try { + try { assert(singletonFrame == nullptr); singletonFrame = this; SetIcon(wxICON(AAArho)); @@ -150,14 +150,22 @@ try { menuBar->EnableTop(1, false); //disable edit menu. // child controls m_LastUsedSqlite.Assign(singletonApp->pConfig->Read(wxT("/Wallet/LastUsed"), wxT(""))); - if (!m_LastUsedSqlite.IsOk() || !m_LastUsedSqlite.HasName() || !m_LastUsedSqlite.HasExt()) { - m_panel = new welcome_to_rhocoin(this); //Owner is "this", via the base class wxFrame. m_panel is a + wxPanel* panel{ nullptr }; + try { + if (m_LastUsedSqlite.IsOk()) + { //Try to load an existing file. + panel = new display_wallet(this, m_LastUsedSqlite); + } + else { + panel = new welcome_to_rhocoin(this); + } + } + catch (const std::exception& e) { + queue_error_message(e.what()); + panel = new welcome_to_rhocoin(this); //Owner is "this", via the base class wxFrame. m_panel is a // non owning pointer in the derived class that duplicates the owning pointer in the base class. } - else { - display_wallet* panel = new display_wallet(this, m_LastUsedSqlite); - m_panel = panel; - } + m_panel = panel; this->RestorePositionFromConfig(ClientToWindowSize(m_panel->GetBestSize())); SetClientSize(GetClientSize()); }