File 0584-observer-Handling-unexpected-wx-event-regarding-sock.patch of Package erlang
From 05a2ef6ed43956800ee77b9988d39cf87ae9b53a Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Fri, 25 Nov 2022 12:15:06 +0100
Subject: [PATCH 1/3] [observer] Handling unexpected wx event regarding sockets
OTP-18339
---
lib/observer/src/observer_sock_wx.erl | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/observer/src/observer_sock_wx.erl b/lib/observer/src/observer_sock_wx.erl
index 3ab8f0d27a..00af44fe47 100644
--- a/lib/observer/src/observer_sock_wx.erl
+++ b/lib/observer/src/observer_sock_wx.erl
@@ -236,14 +236,28 @@ handle_event(#wx{event=#wxSize{size={W,_}}}, State=#state{grid=Grid}) ->
observer_lib:set_listctrl_col_size(Grid, W),
{noreply, State};
+%% handle_event(#wx{event = #wxList{type = command_list_item_activated,
+%% itemIndex = Index}},
+%% State = #state{grid = Grid,
+%% sockets = Sockets,
+%% open_wins = Opened})
+%% when is_list(Sockets) andalso (length(Sockets) >= (Index+1)) ->
+%% Socket = lists:nth(Index+1, Sockets),
+%% NewOpened = display_socket_info(Grid, Socket, Opened),
+%% {noreply, State#state{open_wins = NewOpened}};
handle_event(#wx{event = #wxList{type = command_list_item_activated,
itemIndex = Index}},
State = #state{grid = Grid,
sockets = Sockets,
- open_wins = Opened}) ->
- Socket = lists:nth(Index+1, Sockets),
- NewOpened = display_socket_info(Grid, Socket, Opened),
- {noreply, State#state{open_wins = NewOpened}};
+ open_wins = Opened}) when is_list(Sockets) ->
+ if
+ length(Sockets) >= (Index+1) ->
+ Socket = lists:nth(Index+1, Sockets),
+ NewOpened = display_socket_info(Grid, Socket, Opened),
+ {noreply, State#state{open_wins = NewOpened}};
+ true -> % Race - should we do somthing here?
+ {noreply, State}
+ end;
handle_event(#wx{event = #wxList{type = command_list_item_right_click,
itemIndex = Index}},
--
2.35.3