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,[]},
{included_applications,[]},
{applications,[stdlib,kernel]},
{vsn,"0.1.1"},
{vsn,"0.1.2"},
{modules,[clutch,gmc_con,gmc_grids,gmc_gui,gmc_jt,
gmc_key_master,gmc_sup,gmc_v,gmc_v_netman,
gmc_v_wallman]},

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,9 +2,9 @@
{type,gui}.
{modules,[]}.
{prefix,"gmc"}.
{author,"Craig Everett"}.
{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}},
{"otpr","aesophia",{8,0,1}},
{"otpr","aeserialization",{0,1,2}},