From cf777606f00fa1896c3eb08d9d42ae4c87e94280 Mon Sep 17 00:00:00 2001 From: Mark Chapin Date: Tue, 11 Aug 2026 22:11:35 -0600 Subject: [PATCH] Restore AutoRestartConfirmationDialog handler Reverts the removal in f3b6767. The handler is not defunct: Gateway 10.45 still raises the auto-restart confirmation dialog, and with no handler to dismiss it the modal blocks the configuration dialog from committing, so the TWS API socket port is never applied. Gateway then keeps listening on its default 4001 while IBC's log reports the port as set to 4002, and every API client fails to connect. Confirmed by an A/B of two 3.24.1 builds differing only by this change: handler absent -> binds 4001; dialog Opened, never Closed handler present -> binds 4002; Opened -> "Click button: OK" -> Closed Co-Authored-By: Claude Opus 5 (1M context) --- .../ibc/AutoRestartConfirmationDialog.java | 54 +++++++++++++++++++ src/ibcalpha/ibc/IbcTws.java | 1 + 2 files changed, 55 insertions(+) create mode 100644 src/ibcalpha/ibc/AutoRestartConfirmationDialog.java diff --git a/src/ibcalpha/ibc/AutoRestartConfirmationDialog.java b/src/ibcalpha/ibc/AutoRestartConfirmationDialog.java new file mode 100644 index 00000000..bc502173 --- /dev/null +++ b/src/ibcalpha/ibc/AutoRestartConfirmationDialog.java @@ -0,0 +1,54 @@ +// This file is part of IBC. +// Copyright (C) 2004 Steven M. Kearns (skearns23@yahoo.com ) +// Copyright (C) 2004 - 2022 Richard L King (rlking@aultan.com) +// For conditions of distribution and use, see copyright notice in COPYING.txt + +// IBC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// IBC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with IBC. If not, see . + +package ibcalpha.ibc; + +import java.awt.Window; +import java.awt.event.WindowEvent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; + +public class AutoRestartConfirmationDialog implements WindowHandler { + @Override + public boolean filterEvent(Window window, int eventId) { + switch (eventId) { + case WindowEvent.WINDOW_OPENED: + return true; + default: + return false; + } + } + + @Override + public void handleWindow(Window window, int eventID) { + if (SwingUtils.clickButton(window, "OK")) { + } else { + Utils.logError("could not dismiss AutoRestartConfirmation because we could not find one of the controls."); + } + } + + @Override + public boolean recogniseWindow(Window window) { + if (!(window instanceof JDialog)) return false; + + if (SwingUtils.findTextPane(window, "trading platform restart automatically") != null) return true; + JOptionPane op = SwingUtils.findOptionPane(window); + return (op != null && op.getMessage() != null && op.getMessage().toString().contains("trading platform restart automatically")); + } + +} diff --git a/src/ibcalpha/ibc/IbcTws.java b/src/ibcalpha/ibc/IbcTws.java index 67f883e3..6f46bf26 100644 --- a/src/ibcalpha/ibc/IbcTws.java +++ b/src/ibcalpha/ibc/IbcTws.java @@ -337,6 +337,7 @@ private static List createWindowHandlers() { windowHandlers.add(new BidAskLastSizeDisplayUpdateDialogHandler()); windowHandlers.add(new LoginErrorDialogHandler()); windowHandlers.add(new CryptoOrderConfirmationDialogHandler()); + windowHandlers.add(new AutoRestartConfirmationDialog()); windowHandlers.add(new RestartConfirmationDialogHandler()); windowHandlers.add(new ResetOrderIdConfirmationDialogHandler()); windowHandlers.add(new ReconnectDataOrAccountConfirmationDialogHandler());