diff --git a/controls/dev/Breadcrumb/BreadcrumbBarItem.cpp b/controls/dev/Breadcrumb/BreadcrumbBarItem.cpp index 5313984968..cd026494a7 100644 --- a/controls/dev/Breadcrumb/BreadcrumbBarItem.cpp +++ b/controls/dev/Breadcrumb/BreadcrumbBarItem.cpp @@ -9,6 +9,16 @@ #include "BreadcrumbBar.h" #include "BreadcrumbBarItemAutomationPeer.h" +#include "velocity.h" +#include + +// Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer +#define WINAPPSDK_CHANGEID_48360852 48360852 +// Bug 48634621: [1.4 servicing] File explorer's popup window is hidden by body (z-order issue?) +#define WINAPPSDK_CHANGEID_48634621 48634621 +// Bug 48634543: [1.4 servicing] [Watson Failure] caused by FAIL_FAST_FATAL_APP_EXIT_c0000409_Microsoft.UI.Xaml.Controls.dll!BreadcrumbBarItem::CloneEllipsisItemSource +#define WINAPPSDK_CHANGEID_48634543 48634543 + namespace winrt::Microsoft::UI::Xaml::Controls { CppWinRTActivatableClassWithBasicFactory(BreadcrumbBarItem) @@ -92,6 +102,10 @@ void BreadcrumbBarItem::OnApplyTemplate() if (m_isEllipsisItem) { m_ellipsisFlyout.set(GetTemplateChildT(s_itemEllipsisFlyoutPartName, controlProtected)); + if (WinAppSdk::Containment::IsChangeEnabled()) + { + m_ellipsisFlyout.get().ShouldConstrainToRootBounds(false); + } } m_button.set(GetTemplateChildT(s_itemButtonPartName, controlProtected)); @@ -149,7 +163,14 @@ void BreadcrumbBarItem::SetParentBreadcrumb(const winrt::BreadcrumbBar& parent) { MUX_ASSERT(!m_isEllipsisDropDownItem); - m_parentBreadcrumb.set(parent); + if (WinAppSdk::Containment::IsChangeEnabled()) + { + m_parentBreadcrumbWeakRef = winrt::make_weak(parent); + } + else + { + m_parentBreadcrumb.set(parent); + } } void BreadcrumbBarItem::SetEllipsisDropDownItemDataTemplate(const winrt::IInspectable& newDataTemplate) @@ -180,7 +201,17 @@ void BreadcrumbBarItem::SetIsEllipsisDropDownItem(bool isEllipsisDropDownItem) void BreadcrumbBarItem::RaiseItemClickedEvent(const winrt::IInspectable& content, const uint32_t index) { - if (const auto& breadcrumb = m_parentBreadcrumb.get()) + winrt::BreadcrumbBar breadcrumb; + if (WinAppSdk::Containment::IsChangeEnabled()) + { + breadcrumb = m_parentBreadcrumbWeakRef.get(); + } + else + { + breadcrumb = m_parentBreadcrumb.get(); + } + + if (breadcrumb) { auto breadcrumbImpl = winrt::get_self(breadcrumb); breadcrumbImpl->RaiseItemClickedEvent(content, index); @@ -287,13 +318,27 @@ winrt::IInspectable BreadcrumbBarItem::CloneEllipsisItemSource(const winrt::Coll // The new list contains all the elements in reverse order const int itemsSourceSize = ellipsisItemsSource.Size(); - // The itemsSourceSize should always be at least 1 as it must always contain the ellipsis item - assert(itemsSourceSize > 0); - - for (int i = itemsSourceSize - 1; i >= 0; --i) + if (WinAppSdk::Containment::IsChangeEnabled()) { - const auto& item = ellipsisItemsSource.GetAt(i); - newItemsSource.Append(item); + if(itemsSourceSize > 0) + { + for (int i = itemsSourceSize - 1; i >= 0; --i) + { + const auto& item = ellipsisItemsSource.GetAt(i); + newItemsSource.Append(item); + } + } + } + else + { + // The itemsSourceSize should always be at least 1 as it must always contain the ellipsis item + assert(itemsSourceSize > 0); + + for (int i = itemsSourceSize - 1; i >= 0; --i) + { + const auto& item = ellipsisItemsSource.GetAt(i); + newItemsSource.Append(item); + } } return newItemsSource; @@ -431,7 +476,17 @@ void BreadcrumbBarItem::OnEllipsisItemClick(const winrt::IInspectable&, const wi { MUX_ASSERT(!m_isEllipsisDropDownItem); - if (const auto& breadcrumb = m_parentBreadcrumb.get()) + winrt::BreadcrumbBar breadcrumb; + if (WinAppSdk::Containment::IsChangeEnabled()) + { + breadcrumb = m_parentBreadcrumbWeakRef.get(); + } + else + { + breadcrumb = m_parentBreadcrumb.get(); + } + + if (breadcrumb) { if (const auto& breadcrumbImpl = breadcrumb.try_as()) { @@ -496,7 +551,7 @@ void BreadcrumbBarItem::InstantiateFlyout() { if (const auto& ellipsisFlyout = m_ellipsisFlyout.get()) { - // Create ItemsRepeater and set the DataTemplate + // Create ItemsRepeater and set the DataTemplate const auto& ellipsisItemsRepeater = winrt::ItemsRepeater(); ellipsisItemsRepeater.Name(s_ellipsisItemsRepeaterPartName); winrt::AutomationProperties::SetName(ellipsisItemsRepeater, s_ellipsisItemsRepeaterAutomationName); diff --git a/controls/dev/Breadcrumb/BreadcrumbBarItem.h b/controls/dev/Breadcrumb/BreadcrumbBarItem.h index 67d9ca6ff1..e1c499fc49 100644 --- a/controls/dev/Breadcrumb/BreadcrumbBarItem.h +++ b/controls/dev/Breadcrumb/BreadcrumbBarItem.h @@ -95,8 +95,12 @@ class BreadcrumbBarItem : // BreadcrumbBarItem visual representation tracker_ref m_button{ this }; + // Parent BreadcrumbBarItem to ask for hidden elements + // Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer + // A ref-counted pointer creates a reference cycle and a leak. Switch to the weak pointer when the fix is enabled under containment. tracker_ref m_parentBreadcrumb{ this }; + winrt::weak_ref m_parentBreadcrumbWeakRef{ nullptr }; // Flyout content for ellipsis item tracker_ref m_ellipsisFlyout{ this }; diff --git a/controls/dev/Breadcrumb/BreadcrumbLayout.cpp b/controls/dev/Breadcrumb/BreadcrumbLayout.cpp index da55d17523..a168302187 100644 --- a/controls/dev/Breadcrumb/BreadcrumbLayout.cpp +++ b/controls/dev/Breadcrumb/BreadcrumbLayout.cpp @@ -7,13 +7,26 @@ #include "BreadcrumbBar.h" #include "BreadcrumbBarItem.h" +#include "velocity.h" +#include + +// Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer +#define WINAPPSDK_CHANGEID_48360852 48360852 + BreadcrumbLayout::BreadcrumbLayout() { } BreadcrumbLayout::BreadcrumbLayout(const winrt::BreadcrumbBar& breadcrumb) { - m_breadcrumb = breadcrumb; + if (WinAppSdk::Containment::IsChangeEnabled()) + { + m_breadcrumbWeakRef = winrt::make_weak(breadcrumb); + } + else + { + m_breadcrumb = breadcrumb; + } } BreadcrumbLayout::~BreadcrumbLayout() @@ -61,7 +74,7 @@ winrt::Size BreadcrumbLayout::MeasureOverride(winrt::NonVirtualizingLayoutContex if (accumulatedCrumbsSize.Width > availableSize.Width) { - m_ellipsisIsRendered = true; + m_ellipsisIsRendered = true; } else { @@ -185,9 +198,20 @@ winrt::Size BreadcrumbLayout::ArrangeOverride(winrt::NonVirtualizingLayoutContex } } - if (const auto& breadcrumb = m_breadcrumb.try_as()) + if (WinAppSdk::Containment::IsChangeEnabled()) { - breadcrumb->ReIndexVisibleElementsForAccessibility(); + if (const auto& breadcrumb = m_breadcrumbWeakRef.get()) + { + auto breadcrumbImpl = winrt::get_self(breadcrumb); + breadcrumbImpl->ReIndexVisibleElementsForAccessibility(); + } + } + else + { + if (const auto& breadcrumb = m_breadcrumb.try_as()) + { + breadcrumb->ReIndexVisibleElementsForAccessibility(); + } } return finalSize; diff --git a/controls/dev/Breadcrumb/BreadcrumbLayout.h b/controls/dev/Breadcrumb/BreadcrumbLayout.h index 4c62e1cd98..540c310791 100644 --- a/controls/dev/Breadcrumb/BreadcrumbLayout.h +++ b/controls/dev/Breadcrumb/BreadcrumbLayout.h @@ -41,7 +41,11 @@ class BreadcrumbLayout : winrt::Size m_availableSize{}; winrt::BreadcrumbBarItem m_ellipsisButton{nullptr}; + + // Bug 48360852: [1.4 servicing] BreadcrumbBar leaks in File Explorer + // A ref-counted pointer creates a reference cycle and a leak. Switch to the weak pointer when the fix is enabled under containment. winrt::BreadcrumbBar m_breadcrumb{ nullptr }; + winrt::weak_ref m_breadcrumbWeakRef{ nullptr }; // weak_ref because the BreadcrumbBar already points to us via m_itemsRepeaterLayout bool m_ellipsisIsRendered{}; uint32_t m_firstRenderedItemIndexAfterEllipsis{}; diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 2e4f6b4001..a82486456e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -2,17 +2,17 @@ - + https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDK - e1e38e7e4df1f862ddaac4f4f9a4e77930c55fee + 7d84b710d4c08dc9b8c5506de07bda50c9439369 - + https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP - 3a7a80cf90baf200787d3ffee0443c6a58aacb1f + 2c479f6a2492832f2078a92c9d0489193ff9edba - + https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP - 3a7a80cf90baf200787d3ffee0443c6a58aacb1f + 2c479f6a2492832f2078a92c9d0489193ff9edba diff --git a/packages.config b/packages.config index 452773d96e..adc9d429a0 100644 --- a/packages.config +++ b/packages.config @@ -34,7 +34,7 @@ so we need to pull down this package so we can deploy it to Helix machines. --> - +