From fcfb8d460cbd7bfac0cd842575cecfecad2ef9da Mon Sep 17 00:00:00 2001 From: Jamie Dale Date: Wed, 18 Jun 2014 06:45:31 -0400 Subject: [PATCH] Removed some check() calls when retrieving PlatformInfo for a device TTP# 338166 - CRITICAL: Regression: UFE: CRASH: Deleting a profile under the Advanced section Some places are using this only to get the icon information, so they now use an empty brush should the platform information not be found (it shouldn't really happen, but the device information may sometimes be missing a valid target platform name). Also made sure that any missing icons wouldn't cause list views to misalign their content. #codereview Max.Preussner [CL 2109097 by Jamie Dale in Main branch] --- .../Browser/SDeviceBrowserDeviceAdder.cpp | 10 +++++++--- .../Browser/SDeviceBrowserDeviceListRow.h | 5 +++-- .../Widgets/Browser/SDeviceBrowserFilterBar.cpp | 10 +++++++--- .../Private/Widgets/Shared/SDeviceQuickInfo.h | 9 +++++---- .../Browser/SSessionBrowserInstanceListRow.h | 10 +++++++--- .../Deploy/SSessionLauncherDeviceListRow.h | 17 ++++++++--------- 6 files changed, 37 insertions(+), 24 deletions(-) diff --git a/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceAdder.cpp b/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceAdder.cpp index 1c4d5f9b8250..48b75cab5ebf 100644 --- a/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceAdder.cpp +++ b/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceAdder.cpp @@ -300,7 +300,6 @@ FString SDeviceBrowserDeviceAdder::HandlePlatformComboBoxContentText( ) const TSharedRef SDeviceBrowserDeviceAdder::HandlePlatformComboBoxGenerateWidget( TSharedPtr Item ) { const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(**Item); - check(PlatformInfo); return SNew(SHorizontalBox) @@ -309,8 +308,13 @@ TSharedRef SDeviceBrowserDeviceAdder::HandlePlatformComboBoxGenerateWid .AutoWidth() .HAlign(HAlign_Left) [ - SNew(SImage) - .Image(FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal))) + SNew(SBox) + .WidthOverride(24) + .HeightOverride(24) + [ + SNew(SImage) + .Image((PlatformInfo) ? FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal)) : FStyleDefaults::GetNoBrush()) + ] ] + SHorizontalBox::Slot() diff --git a/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceListRow.h b/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceListRow.h index 3d1595107228..bfb67135b278 100644 --- a/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceListRow.h +++ b/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserDeviceListRow.h @@ -62,13 +62,14 @@ public: else if (ColumnName == TEXT("Icon")) { const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(*DeviceService->GetDeviceId().GetPlatformName()); - check(PlatformInfo); return SNew(SBox) .Padding(FMargin(4.0f, 0.0f)) + .WidthOverride(24) + .HeightOverride(24) [ SNew(SImage) - .Image(FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal))) + .Image((PlatformInfo) ? FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal)) : FStyleDefaults::GetNoBrush()) ]; } else if (ColumnName == TEXT("Name")) diff --git a/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserFilterBar.cpp b/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserFilterBar.cpp index e253e55edf97..cc27bdb69ef7 100644 --- a/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserFilterBar.cpp +++ b/Engine/Source/Developer/DeviceManager/Private/Widgets/Browser/SDeviceBrowserFilterBar.cpp @@ -110,7 +110,6 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION TSharedRef SDeviceBrowserFilterBar::HandlePlatformListViewGenerateRow( TSharedPtr PlatformName, const TSharedRef& OwnerTable ) { const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(**PlatformName); - check(PlatformInfo); return SNew(STableRow >, OwnerTable) .Content() @@ -126,8 +125,13 @@ TSharedRef SDeviceBrowserFilterBar::HandlePlatformListViewGenerateRow + SHorizontalBox::Slot() .AutoWidth() [ - SNew(SImage) - .Image(FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal))) + SNew(SBox) + .WidthOverride(24) + .HeightOverride(24) + [ + SNew(SImage) + .Image((PlatformInfo) ? FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal)) : FStyleDefaults::GetNoBrush()) + ] ] + SHorizontalBox::Slot() diff --git a/Engine/Source/Developer/DeviceManager/Private/Widgets/Shared/SDeviceQuickInfo.h b/Engine/Source/Developer/DeviceManager/Private/Widgets/Shared/SDeviceQuickInfo.h index 61e44ba0953a..cf9616b46f69 100644 --- a/Engine/Source/Developer/DeviceManager/Private/Widgets/Shared/SDeviceQuickInfo.h +++ b/Engine/Source/Developer/DeviceManager/Private/Widgets/Shared/SDeviceQuickInfo.h @@ -242,12 +242,13 @@ private: if (DeviceService.IsValid()) { const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(*DeviceService->GetDeviceId().GetPlatformName()); - check(PlatformInfo); - - return FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::XLarge)); + if(PlatformInfo) + { + return FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::XLarge)); + } } - return NULL; + return FStyleDefaults::GetNoBrush(); } // Callback for getting the name of the device's platform. diff --git a/Engine/Source/Developer/SessionFrontend/Private/Widgets/Browser/SSessionBrowserInstanceListRow.h b/Engine/Source/Developer/SessionFrontend/Private/Widgets/Browser/SSessionBrowserInstanceListRow.h index 8f7d61edd463..498502c9f5a9 100644 --- a/Engine/Source/Developer/SessionFrontend/Private/Widgets/Browser/SSessionBrowserInstanceListRow.h +++ b/Engine/Source/Developer/SessionFrontend/Private/Widgets/Browser/SSessionBrowserInstanceListRow.h @@ -95,7 +95,6 @@ public: else if (ColumnName == "Platform") { const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(*InstanceInfo->GetPlatformName()); - check(PlatformInfo); return SNew(SHorizontalBox) @@ -103,8 +102,13 @@ public: .AutoWidth() .VAlign(VAlign_Center) [ - SNew(SImage) - .Image(FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal))) + SNew(SBox) + .WidthOverride(24) + .HeightOverride(24) + [ + SNew(SImage) + .Image((PlatformInfo) ? FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal)) : FStyleDefaults::GetNoBrush()) + ] ] + SHorizontalBox::Slot() diff --git a/Engine/Source/Developer/SessionLauncher/Private/Widgets/Deploy/SSessionLauncherDeviceListRow.h b/Engine/Source/Developer/SessionLauncher/Private/Widgets/Deploy/SSessionLauncherDeviceListRow.h index 0f1d9f577e19..51807450165e 100644 --- a/Engine/Source/Developer/SessionLauncher/Private/Widgets/Deploy/SSessionLauncherDeviceListRow.h +++ b/Engine/Source/Developer/SessionLauncher/Private/Widgets/Deploy/SSessionLauncherDeviceListRow.h @@ -75,8 +75,13 @@ public: + SHorizontalBox::Slot() .AutoWidth() [ - SNew(SImage) - .Image(this, &SSessionLauncherDeviceListRow::HandleDeviceImage) + SNew(SBox) + .WidthOverride(24) + .HeightOverride(24) + [ + SNew(SImage) + .Image(this, &SSessionLauncherDeviceListRow::HandleDeviceImage) + ] ] + SHorizontalBox::Slot() @@ -165,13 +170,7 @@ private: const FSlateBrush* HandleDeviceImage( ) const { const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(*DeviceProxy->GetPlatformName()); - - if (PlatformInfo == nullptr) - { - return nullptr; - } - - return FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal)); + return (PlatformInfo) ? FEditorStyle::GetBrush(PlatformInfo->GetIconStyleName(PlatformInfo::EPlatformIconSize::Normal)) : FStyleDefaults::GetNoBrush(); } // Callback for getting the friendly name.