Fix a few wallet switching crashes

This commit is contained in:
Craig Everett 2024-11-13 13:19:45 +09:00
parent 4cecb23001
commit 22b94994bb
12 changed files with 27 additions and 17 deletions

View File

@ -3,7 +3,7 @@
{registered,[]}, {registered,[]},
{included_applications,[]}, {included_applications,[]},
{applications,[stdlib,kernel]}, {applications,[stdlib,kernel]},
{vsn,"0.1.1"}, {vsn,"0.1.2"},
{modules,[clutch,gmc_con,gmc_grids,gmc_gui,gmc_jt, {modules,[clutch,gmc_con,gmc_grids,gmc_gui,gmc_jt,
gmc_key_master,gmc_sup,gmc_v,gmc_v_netman, gmc_key_master,gmc_sup,gmc_v,gmc_v_netman,
gmc_v_wallman]}, gmc_v_wallman]},

View File

@ -3,7 +3,7 @@
%%% @end %%% @end
-module(clutch). -module(clutch).
-vsn("0.1.1"). -vsn("0.1.2").
-behavior(application). -behavior(application).
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(gmc_con). -module(gmc_con).
-vsn("0.1.1"). -vsn("0.1.2").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
@ -324,6 +324,8 @@ handle_cast({open_wallet, Path, Phrase}, State) ->
{noreply, NewState}; {noreply, NewState};
handle_cast(close_wallet, State) -> handle_cast(close_wallet, State) ->
NewState = do_close_wallet(State), NewState = do_close_wallet(State),
ok = gmc_gui:show([]),
ok = do_show_ui(gmc_v_wallman, NewState),
{noreply, NewState}; {noreply, NewState};
handle_cast({new_wallet, Name, Path, Password}, State) -> handle_cast({new_wallet, Name, Path, Password}, State) ->
NewState = do_new_wallet(Name, Path, Password, State), NewState = do_new_wallet(Name, Path, Password, State),
@ -1050,9 +1052,7 @@ do_close_wallet(State = #s{wallet = Current, wallets = Wallets, pass = Pass}) ->
#wallet{name = Name} = Current, #wallet{name = Name} = Current,
RW = lists:keyfind(Name, #wr.name, Wallets), RW = lists:keyfind(Name, #wr.name, Wallets),
ok = save_wallet(RW, Pass, Current), ok = save_wallet(RW, Pass, Current),
ok = gmc_gui:show([]), State#s{pass = none, wallet = none}.
ok = do_show_ui(gmc_v_wallman, State),
State#s{pass = false, wallet = none}.
save_wallet(#wr{path = Path, pass = false}, none, Wallet) -> save_wallet(#wr{path = Path, pass = false}, none, Wallet) ->

View File

@ -37,7 +37,7 @@
%%% @end %%% @end
-module(gmc_grids). -module(gmc_grids).
-vsn("0.1.1"). -vsn("0.1.2").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").

View File

@ -7,7 +7,7 @@
%%% @end %%% @end
-module(gmc_gui). -module(gmc_gui).
-vsn("0.1.1"). -vsn("0.1.2").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
@ -869,7 +869,7 @@ do_show(Accounts, State = #s{sizer = Sizer, prefs = Prefs, picker = Picker}) ->
NewState = NewState =
case Accounts of case Accounts of
[] -> [] ->
State; clear_account(State);
[_] -> [_] ->
Selected = 0, Selected = 0,
ok = wxListBox:setSelection(Picker, Selected), ok = wxListBox:setSelection(Picker, Selected),
@ -882,6 +882,11 @@ do_show(Accounts, State = #s{sizer = Sizer, prefs = Prefs, picker = Picker}) ->
ok = wxSizer:layout(Sizer), ok = wxSizer:layout(Sizer),
NewState. NewState.
clear_account(State = #s{balance = {_, #w{wx = B}}, id = {_, #w{wx = I}}}) ->
ok = wxStaticText:setLabel(I, ""),
ok = wxStaticText:setLabel(B, ""),
State.
do_wallet(none, #s{buttons = Buttons}) -> do_wallet(none, #s{buttons = Buttons}) ->
#w{wx = WalletB} = lists:keyfind(wallet, #w.name, Buttons), #w{wx = WalletB} = lists:keyfind(wallet, #w.name, Buttons),

View File

@ -15,7 +15,7 @@
%%% translation library is retained). %%% translation library is retained).
-module(gmc_jt). -module(gmc_jt).
-vsn("0.1.1"). -vsn("0.1.2").
-export([read_translations/1, j/2, oneshot_j/2]). -export([read_translations/1, j/2, oneshot_j/2]).

View File

@ -8,7 +8,7 @@
%%% @end %%% @end
-module(gmc_key_master). -module(gmc_key_master).
-vsn("0.1.1"). -vsn("0.1.2").
-export([make_key/2, encode/1, decode/1]). -export([make_key/2, encode/1, decode/1]).

View File

@ -12,7 +12,7 @@
%%% @end %%% @end
-module(gmc_sup). -module(gmc_sup).
-vsn("0.1.1"). -vsn("0.1.2").
-behaviour(supervisor). -behaviour(supervisor).
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").

View File

@ -1,5 +1,5 @@
-module(gmc_v). -module(gmc_v).
-vsn("0.1.1"). -vsn("0.1.2").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").

View File

@ -1,5 +1,5 @@
-module(gmc_v_netman). -module(gmc_v_netman).
-vsn("0.1.1"). -vsn("0.1.2").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").

View File

@ -1,5 +1,5 @@
-module(gmc_v_wallman). -module(gmc_v_wallman).
-vsn("0.1.1"). -vsn("0.1.2").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("QPQ AG <info@qpq.swiss>"). -copyright("QPQ AG <info@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
@ -245,6 +245,7 @@ do_open3(Path, State = #s{frame = Frame, j = J}) ->
do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) -> do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
tell("new_wallet ~p/~p ~p", [?FUNCTION_NAME, ?FUNCTION_ARITY, ?LINE]),
DefaultDir = maps:get(dir, Prefs, zx_lib:path(var, "otpr", "clutch")), DefaultDir = maps:get(dir, Prefs, zx_lib:path(var, "otpr", "clutch")),
Options = Options =
[{message, J("Save Location")}, [{message, J("Save Location")},
@ -272,6 +273,7 @@ do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
end. end.
do_new2(Path, J, Frame) -> do_new2(Path, J, Frame) ->
tell("new_wallet ~p/~p ~p", [?FUNCTION_NAME, ?FUNCTION_ARITY, ?LINE]),
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Set Node"), [{size, {400, 250}}]), Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Set Node"), [{size, {400, 250}}]),
Sizer = wxBoxSizer:new(?wxVERTICAL), Sizer = wxBoxSizer:new(?wxVERTICAL),
@ -306,6 +308,7 @@ do_new2(Path, J, Frame) ->
Result = Result =
case wxDialog:showModal(Dialog) of case wxDialog:showModal(Dialog) of
?wxID_OK -> ?wxID_OK ->
tell("new_wallet ~p/~p ~p", [?FUNCTION_NAME, ?FUNCTION_ARITY, ?LINE]),
Name = Name =
case wxTextCtrl:getValue(NameTx) of case wxTextCtrl:getValue(NameTx) of
"" -> Path; "" -> Path;
@ -325,8 +328,10 @@ do_new2(Path, J, Frame) ->
Result. Result.
do_new3(_, _, bad) -> do_new3(_, _, bad) ->
tell("new_wallet ~p/~p ~p", [?FUNCTION_NAME, ?FUNCTION_ARITY, ?LINE]),
abort; abort;
do_new3(Name, Path, Pass) -> do_new3(Name, Path, Pass) ->
tell("new_wallet ~p/~p ~p", [?FUNCTION_NAME, ?FUNCTION_ARITY, ?LINE]),
gmc_con:new_wallet(Name, Path, Pass). gmc_con:new_wallet(Name, Path, Pass).

View File

@ -2,9 +2,9 @@
{type,gui}. {type,gui}.
{modules,[]}. {modules,[]}.
{prefix,"gmc"}. {prefix,"gmc"}.
{author,"Craig Everett"}.
{desc,"A desktop client for the Gajumaru network of blockchain networks"}. {desc,"A desktop client for the Gajumaru network of blockchain networks"}.
{package_id,{"otpr","clutch",{0,1,1}}}. {author,"Craig Everett"}.
{package_id,{"otpr","clutch",{0,1,2}}}.
{deps,[{"otpr","hakuzaru",{0,2,0}}, {deps,[{"otpr","hakuzaru",{0,2,0}},
{"otpr","aesophia",{8,0,1}}, {"otpr","aesophia",{8,0,1}},
{"otpr","aeserialization",{0,1,2}}, {"otpr","aeserialization",{0,1,2}},