From 954b991caf7ccc2c8c05dd138a68a195535a2059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Tue, 27 Mar 2012 22:21:35 +0100 Subject: [PATCH] Fixes for rare AvalonDock bugs: - Exception when closing tab by middle-clicking - Exception when hovering over auto-hide pad --- src/Libraries/AvalonDock/AvalonDock/DockingManager.cs | 9 +++++++++ src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs index 45a393e3fa..b65cdc147d 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs @@ -2636,6 +2636,15 @@ namespace AvalonDock //_flyoutWindow.KeepWindowOpen(); return; } + + // David: This sometimes seems to be null when hovering over auto-hide pad. + // It only seems to occur in specific circumstances - whether the pad is the + // "selected" one in the set seems important. Having no open document might have effect? + // I have only managed to reliablely reproduce it in stand-alone application. + if (content.ContainerPane == null) + { + return; + } //hide previous window HideFlyoutWindow(); diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs index b4ed1cf282..86c963cc92 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs @@ -65,6 +65,10 @@ namespace AvalonDock foreach (ManagedContent child in Children) { + // David: Sometimes happened when closing document tab by middle clicking. Really difficult to reproduce. + if (child == null) + continue; + Panel.SetZIndex(child, Selector.GetIsSelected(child) ? 1 : -i); i++; child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); @@ -81,6 +85,10 @@ namespace AvalonDock bool skipAllOthers = false; foreach (ManagedContent doc in Children) { + // David: Sometimes happened when closing document tab by middle clicking. Really difficult to reproduce. + if (doc == null) + continue; + if (skipAllOthers || offset + doc.DesiredSize.Width > finalSize.Width) { SetIsHeaderVisible(doc, false);