handle exception while attempting to open an existing wallet

This commit is contained in:
Cheng 2023-02-24 11:33:09 +08:00
parent 003d671c25
commit a478a79e8b
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA

View File

@ -65,7 +65,7 @@ Frame::Frame(wxString wxs)
m_panel(), m_panel(),
m_LastUsedSqlite() m_LastUsedSqlite()
{ {
try { try {
assert(singletonFrame == nullptr); assert(singletonFrame == nullptr);
singletonFrame = this; singletonFrame = this;
SetIcon(wxICON(AAArho)); SetIcon(wxICON(AAArho));
@ -150,14 +150,22 @@ try {
menuBar->EnableTop(1, false); //disable edit menu. menuBar->EnableTop(1, false); //disable edit menu.
// child controls // child controls
m_LastUsedSqlite.Assign(singletonApp->pConfig->Read(wxT("/Wallet/LastUsed"), wxT(""))); m_LastUsedSqlite.Assign(singletonApp->pConfig->Read(wxT("/Wallet/LastUsed"), wxT("")));
if (!m_LastUsedSqlite.IsOk() || !m_LastUsedSqlite.HasName() || !m_LastUsedSqlite.HasExt()) { wxPanel* panel{ nullptr };
m_panel = new welcome_to_rhocoin(this); //Owner is "this", via the base class wxFrame. m_panel is a 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. // non owning pointer in the derived class that duplicates the owning pointer in the base class.
} }
else { m_panel = panel;
display_wallet* panel = new display_wallet(this, m_LastUsedSqlite);
m_panel = panel;
}
this->RestorePositionFromConfig(ClientToWindowSize(m_panel->GetBestSize())); this->RestorePositionFromConfig(ClientToWindowSize(m_panel->GetBestSize()));
SetClientSize(GetClientSize()); SetClientSize(GetClientSize());
} }