From 25ec24936f1d8e07b3f0cc2ad78eb9fdc6ead80e Mon Sep 17 00:00:00 2001 From: Cheng Date: Fri, 20 May 2022 20:12:37 +1000 Subject: [PATCH] putting it to bed before minor refactoring Realized delete was not rightly part of the frame And close rightly part of the frame, rather than the rightly part of the wallet display, so, putting current work to bed before changing those things --- display_wallet.cpp | 1 + frame.cpp | 13 +++++++------ frame.h | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/display_wallet.cpp b/display_wallet.cpp index 7ffb25f..01c0c76 100644 --- a/display_wallet.cpp +++ b/display_wallet.cpp @@ -103,4 +103,5 @@ void display_wallet::OnClose(wxCloseEvent& event) { Destroy(); //Default handler will destroy the window. This is our handler for the user calling close, // replacing the default handler.' if (singletonFrame->m_panel ==this)singletonFrame->m_panel = nullptr; + } \ No newline at end of file diff --git a/frame.cpp b/frame.cpp index 78a203f..70db891 100644 --- a/frame.cpp +++ b/frame.cpp @@ -128,11 +128,9 @@ try { menuFile->Append(wxID_OPEN, menu_strings[0].tail[2][0], menu_strings[0].tail[2][1]); menuFile->Bind(wxEVT_MENU, &Frame::OnFileOpen, this, wxID_OPEN); - menuFile->Append(wxID_DELETE, menu_strings[0].tail[3][0], menu_strings[0].tail[3][1] + m_LastUsedSqlite.GetFullPath()); wxLogMessage(m_LastUsedSqlite.GetFullPath()+" wallet path"); - menuFile->Bind(wxEVT_MENU, &Frame::OnDelete, this, wxID_DELETE); - menuFile->Append(myID_DELETECONFIG, menu_strings[0].tail[4][0], menu_strings[0].tail[4][1] + m_LastUsedSqlite.GetFullPath()); + menuFile->Bind(wxEVT_MENU, &Frame::OnDelete, this, wxID_DELETE); menuFile->Append(myID_DELETECONFIG, menu_strings[0].tail[4][0], menu_strings[0].tail[4][1] + m_LastUsedSqlite.GetFullPath()); menuFile->Bind(wxEVT_MENU, &Frame::OnDeleteConfiguration, this, myID_DELETECONFIG); menuFile->Append(myID_MYEXIT,"my exit, testing destruction"); menuFile->Bind(wxEVT_MENU, &Frame::OnMyCloseMpanel, this, myID_MYEXIT); @@ -346,6 +344,7 @@ void Frame::OnDelete(wxCommandEvent& WXUNUSED(event)) if (LastUsedSqlite.IsOk() && LastUsedSqlite.FileExists()) { if (wxRemoveFile(LastUsedSqlite.GetFullPath()))wxLogMessage(_T("Deleting % s"), LastUsedSqlite.GetFullPath()); } + LastUsedSqlite.Clear(); } void Frame::OnMenuOpen(wxMenuEvent& evt) { @@ -356,11 +355,13 @@ void Frame::OnMenuOpen(wxMenuEvent& evt) { } } -Frame::~Frame(){ +Frame::~Frame() { assert(singletonFrame == this); singletonFrame = nullptr; - wxConfigBase *pConfig = wxConfigBase::Get(); + wxConfigBase* pConfig = wxConfigBase::Get(); if (pConfig == nullptr)return; StorePositionToConfig(); - pConfig->Write(_T("/Wallet/LastUsed"), m_LastUsedSqlite.GetFullPath()); + if (singletonApp->pConfig->Read(_T("/Wallet/LastUsed"), _T("")) != m_LastUsedSqlite.GetFullPath()) { + pConfig->Write(_T("/Wallet/LastUsed"), m_LastUsedSqlite.GetFullPath()); + } } diff --git a/frame.h b/frame.h index 5199aad..6f8e31d 100644 --- a/frame.h +++ b/frame.h @@ -75,6 +75,7 @@ private: void OnDeleteConfiguration(wxCommandEvent&); void OnMyCloseMpanel(wxCommandEvent&); + public: void OnSaveNew(wxCommandEvent&); void NewWallet(wxFileName&, ristretto255::hash<256>&); @@ -82,9 +83,9 @@ public: void OnFileOpen(wxCommandEvent&); private: - void OnDelete(wxCommandEvent&); void OnMenuOpen(wxMenuEvent&); public: + void OnDelete(wxCommandEvent&); void OnFirstUse(wxCommandEvent&); public: