diff options
author | visciang <[email protected]> | 2017-01-26 11:18:12 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2017-01-26 11:18:12 +0100 |
commit | 15dd52f771314b6eade47314afcd8b3206c694b1 (patch) | |
tree | 1f3a9fd6dc693de52f30e968d56748880399aedd /lib/observer/src/observer_port_wx.erl | |
parent | cd4a95b0abb45f07eef8a77991c2be8f5dea575e (diff) | |
download | otp-15dd52f771314b6eade47314afcd8b3206c694b1.tar.gz otp-15dd52f771314b6eade47314afcd8b3206c694b1.tar.bz2 otp-15dd52f771314b6eade47314afcd8b3206c694b1.zip |
Fix observer application crash (#1296)
Fix observer application crash
When clicking an HTML-link to a port before the port tab has been opened for the first time, observer would crash since port info is not initiated. This is now corrected.
Also, when clicking on an HTML link to a port, and the port does not exist,
then pop up an info dialog saying "No such port".
OTP-14151
Diffstat (limited to 'lib/observer/src/observer_port_wx.erl')
-rw-r--r-- | lib/observer/src/observer_port_wx.erl | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/observer/src/observer_port_wx.erl b/lib/observer/src/observer_port_wx.erl index 53ba3fa607..c21d2705c0 100644 --- a/lib/observer/src/observer_port_wx.erl +++ b/lib/observer/src/observer_port_wx.erl @@ -267,10 +267,19 @@ handle_cast(Event, _State) -> error({unhandled_cast, Event}). handle_info({portinfo_open, PortIdStr}, - State = #state{grid=Grid, ports=Ports, open_wins=Opened}) -> - Port = lists:keyfind(PortIdStr,#port.id_str,Ports), - NewOpened = display_port_info(Grid, Port, Opened), - {noreply, State#state{open_wins = NewOpened}}; + State = #state{node=Node, grid=Grid, opt=Opt, open_wins=Opened}) -> + Ports0 = get_ports(Node), + Ports = update_grid(Grid, Opt, Ports0), + Port = lists:keyfind(PortIdStr, #port.id_str, Ports), + NewOpened = + case Port of + false -> + self() ! {error,"No such port: " ++ PortIdStr}, + Opened; + _ -> + display_port_info(Grid, Port, Opened) + end, + {noreply, State#state{ports=Ports, open_wins=NewOpened}}; handle_info(refresh_interval, State = #state{node=Node, grid=Grid, opt=Opt, ports=OldPorts}) -> @@ -296,8 +305,9 @@ handle_info(not_active, State = #state{timer = Timer0}) -> Timer = observer_lib:stop_timer(Timer0), {noreply, State#state{timer=Timer}}; -handle_info({error, Error}, State) -> - handle_error(Error), +handle_info({error, Error}, #state{panel=Panel} = State) -> + Str = io_lib:format("ERROR: ~s~n",[Error]), + observer_lib:display_info_dialog(Panel, Str), {noreply, State}; handle_info(_Event, State) -> @@ -501,11 +511,6 @@ filter_monitor_info() -> [Pid || {process, Pid} <- Ms] end. - -handle_error(Foo) -> - Str = io_lib:format("ERROR: ~s~n",[Foo]), - observer_lib:display_info_dialog(Str). - update_grid(Grid, Opt, Ports) -> wx:batch(fun() -> update_grid2(Grid, Opt, Ports) end). update_grid2(Grid, #opt{sort_key=Sort,sort_incr=Dir}, Ports) -> |