fixed add name UI

Error handling in add name still horribly broken
This commit is contained in:
Cheng 2023-02-24 13:30:54 +08:00
parent 55929ac9c8
commit 5b37e32a81
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA
3 changed files with 18 additions and 8 deletions

View File

@ -183,12 +183,15 @@ class sql_insert_name {
ro::sql csql_into_names; ro::sql csql_into_names;
ro::sql csql_namekey_into_keys; ro::sql csql_namekey_into_keys;
ro::sql csql_commit; ro::sql csql_commit;
ro::sql csql_rollback;
public: public:
sql_insert_name(ISqlite3* p) : sql_insert_name(ISqlite3* p) :
csql_begin(p, R"|(BEGIN;)|"), csql_begin(p, R"|(BEGIN;)|"),
csql_into_names(p, R"|(INSERT OR ROLLBACK INTO "Names" VALUES(?1);)|"), csql_into_names(p, R"|(INSERT OR ROLLBACK INTO "Names" VALUES(?1);)|"),
csql_namekey_into_keys(p, R"|(INSERT OR ROLLBACK INTO "Keys" VALUES(?1, last_insert_rowid(), 1);)|"), csql_namekey_into_keys(p, R"|(INSERT OR ROLLBACK INTO "Keys" VALUES(?1, last_insert_rowid(), 1);)|"),
csql_commit(p, R"|(COMMIT;)|") {} csql_commit(p, R"|(COMMIT;)|"),
csql_rollback(p, R"|(ROLLBACK;)|")
{}
sql_insert_name(const std::unique_ptr<ISqlite3>& p) : sql_insert_name(p.get()) {} sql_insert_name(const std::unique_ptr<ISqlite3>& p) : sql_insert_name(p.get()) {}
void operator()(const char* psz, const ristretto255::point& pt) { void operator()(const char* psz, const ristretto255::point& pt) {
csql_begin.do_one(); csql_begin.do_one();
@ -197,7 +200,7 @@ public:
csql_namekey_into_keys.do_one(pt); csql_namekey_into_keys.do_one(pt);
} }
catch (const std::exception & e) { catch (const std::exception & e) {
csql_commit.do_one(); csql_rollback.do_one();
throw e; throw e;
} }
csql_commit.do_one(); csql_commit.do_one();

View File

@ -79,10 +79,10 @@ void display_wallet::close_menu_event_handler(wxCommandEvent& event) {
void display_wallet::add_name_event_handler(wxCommandEvent& event) { void display_wallet::add_name_event_handler(wxCommandEvent& event) {
wxTextEntryDialog dialog(this, wxTextEntryDialog dialog(this,
"This is a small sample\n" R"("A Zooko name has a human readable name,
"A long, long string to test out the text entrybox", and a public key defined by the name and the wallet master secret)",
"Please enter a string", "Create a Zooko name",
"Default value", "",
wxOK | wxCANCEL); wxOK | wxCANCEL);
if (dialog.ShowModal() == wxID_OK) if (dialog.ShowModal() == wxID_OK)
{ {

View File

@ -161,10 +161,17 @@ Frame::Frame(wxString wxs)
} }
} }
catch (const std::exception& e) { catch (const std::exception& e) {
// if the attempt to load an existing wallet file fails,
// we have to complete startup somehow.
queue_error_message(e.what()); queue_error_message(e.what());
panel = new welcome_to_rhocoin(this); //Owner is "this", via the base class wxFrame. m_panel is a panel = new welcome_to_rhocoin(this); //Owner is "this", via the base class wxFrame.
// non owning pointer in the derived class that duplicates the owning pointer in the base class.
} }
// m_panel is a non owning pointer in the derived class that duplicates the
// owning pointer in the base class. This looks like a violation of DIY.
// but I have the concept of the primary child of the frame window, while
// wxWidgets lacks that concept.
// m_panel signifies the child window of the frame that currently matters.
m_panel = panel; m_panel = panel;
this->RestorePositionFromConfig(ClientToWindowSize(m_panel->GetBestSize())); this->RestorePositionFromConfig(ClientToWindowSize(m_panel->GetBestSize()));
SetClientSize(GetClientSize()); SetClientSize(GetClientSize());