diff --git a/GCSViews/FlightData.cs b/GCSViews/FlightData.cs index 0a4a5ab60d..bc4128db1d 100644 --- a/GCSViews/FlightData.cs +++ b/GCSViews/FlightData.cs @@ -6469,20 +6469,16 @@ private void jumpToTagToolStripMenuItem_Click(object sender, EventArgs e) ToolStripMenuItem gimbalVideoShowMiniMap = new ToolStripMenuItem("Mini map"); ToolStripMenuItem gimbalVideoSwapPosition = new ToolStripMenuItem("Swap with map"); ToolStripMenuItem gimbalVideoClose = new ToolStripMenuItem("Close"); + bool gimbalMenuHandlersInitialized = false; GimbalVideoControl _gimbalVideoControl; GimbalVideoControl gimbalVideoControl { get { - // Check if we need to construct a gimbalVideoControl - if (_gimbalVideoControl == null || _gimbalVideoControl.IsDisposed) + // If this is the first call, create the handlers for the context menu items + if (!gimbalMenuHandlersInitialized) { - _gimbalVideoControl = new GimbalVideoControl(); - _gimbalVideoControl.Dock = DockStyle.Fill; - - // Add option to show/hide minimap - gimbalVideoShowMiniMap.CheckOnClick = true; - gimbalVideoShowMiniMap.Checked = true; + gimbalMenuHandlersInitialized = true; gimbalVideoShowMiniMap.CheckedChanged += (s, ev) => { gMapControl1.Visible = gimbalVideoShowMiniMap.Checked; @@ -6506,6 +6502,16 @@ GimbalVideoControl gimbalVideoControl gimbalVideoControl.Stop(); gimbalVideoControl.Dispose(); }; + } + // Check if we need to construct a gimbalVideoControl + if (_gimbalVideoControl == null || _gimbalVideoControl.IsDisposed) + { + _gimbalVideoControl = new GimbalVideoControl(); + _gimbalVideoControl.Dock = DockStyle.Fill; + + // Add option to show/hide minimap + gimbalVideoShowMiniMap.CheckOnClick = true; + gimbalVideoShowMiniMap.Checked = true; _gimbalVideoControl.VideoBoxContextMenu.Items.Add(gimbalVideoShowMiniMap); _gimbalVideoControl.VideoBoxContextMenu.Items.Add(gimbalVideoSwapPosition);