Skip to content

Commit 449e3b8

Browse files
chore: fix potential crash due to garbage collection (#3671)
1 parent 2e6f513 commit 449e3b8

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

Source/SampleGame426/Public/UI/Inventory/SearchNFTsWidget.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SAMPLEGAME426_API USearchNfTsWidget : public UActivatableWidgetWithControl
3939
virtual void NativeOnActivated() override;
4040
virtual void NativeOnDeactivated() override;
4141
/* UActivatableWidget interface */
42-
42+
4343
/* UActivatableWidgetWithControlPanels interface */
4444
virtual void SetupControlButtons(class UAWStackWithControlPanels* HostLayer) override;
4545
/* UActivatableWidgetWithControlPanels interface */
@@ -58,7 +58,7 @@ class SAMPLEGAME426_API USearchNfTsWidget : public UActivatableWidgetWithControl
5858
* @param ItemWidget A pointer to the UItemWidget representing the item.
5959
*/
6060
void OnItemSelection(bool IsSelected, UItemWidget* ItemWidget);
61-
61+
6262
private:
6363
/**
6464
* Handles the pagination of inventory API query results.
@@ -118,7 +118,7 @@ class SAMPLEGAME426_API USearchNfTsWidget : public UActivatableWidgetWithControl
118118
*/
119119
UFUNCTION()
120120
void OnProcessDialogAction(UDialog* DialogPtr, EDialogResult Result);
121-
121+
122122
void ConfirmListing(const FString& ListingId);
123123
void OnGetListing(const ImmutablezkEVMAPI::APIOrdersApi::GetListingResponse& Response);
124124

@@ -130,12 +130,20 @@ class SAMPLEGAME426_API USearchNfTsWidget : public UActivatableWidgetWithControl
130130
UPROPERTY(Transient)
131131
UControlPanelButton* NextPageButton = nullptr;
132132

133-
private:
133+
protected:
134134
TWeakObjectPtr<UMarketplacePolicy> Policy;
135-
USearchNFTsItemWidget* SelectedItemWidget = nullptr;
135+
136136
ImmutablezkEVMAPI::APIPage PageCursors;
137-
UControlPanelButton* SellButton = nullptr;
138-
UControlPanelButton* CancelSellButton = nullptr;
139-
UDialog* ProcessingDialog = nullptr;
140137

141-
};
138+
UPROPERTY(BlueprintReadOnly)
139+
TObjectPtr<USearchNFTsItemWidget> SelectedItemWidget;
140+
141+
UPROPERTY(BlueprintReadOnly)
142+
TObjectPtr<UControlPanelButton> SellButton;
143+
144+
UPROPERTY(BlueprintReadOnly)
145+
TObjectPtr<UControlPanelButton> CancelSellButton;
146+
147+
UPROPERTY(BlueprintReadOnly)
148+
TObjectPtr<UDialog> ProcessingDialog;
149+
};

Source/SampleGame426/Public/UI/Marketplace/SearchStacksListingWidget.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "SearchStacksListingWidget.generated.h"
99

10-
1110
/**
1211
* @class USearchStacksListingWidget
1312
* @ingroup Marketplace
@@ -26,10 +25,10 @@ class SAMPLEGAME426_API USearchStacksListingWidget : public UActivatableWidgetWi
2625
/* IMarketplaceOpenAPIProcessorInterface interface */
2726

2827
/* UActivatableWidgetWithControlPanels interface */
29-
virtual void SetupControlButtons(class UAWStackWithControlPanels* HostLayer) override;
28+
virtual void SetupControlButtons(class UAWStackWithControlPanels* HostLayer) override;
3029
virtual void Refresh() override;
3130
/* UActivatableWidgetWithControlPanels interface */
32-
31+
3332
protected:
3433
/**
3534
* Adds a NFT general information such as description, dates etc.
@@ -124,12 +123,16 @@ class SAMPLEGAME426_API USearchStacksListingWidget : public UActivatableWidgetWi
124123
*/
125124
void OnControlButtonClicked(FGameplayTag ButtonTag);
126125

127-
128126
protected:
129127
UPROPERTY(BlueprintReadOnly, meta=(BindWidget))
130128
class USearchStacksListing_ListingsWidget* Listings = nullptr;
131129

132-
UItemWidget* SelectedItem = nullptr;
130+
UPROPERTY(BlueprintReadOnly)
131+
TObjectPtr<UItemWidget> SelectedItem = nullptr;
132+
133+
UPROPERTY(BlueprintReadOnly)
133134
UControlPanelButton* BuyButton = nullptr;
135+
136+
UPROPERTY(BlueprintReadOnly)
134137
UDialog* ProcessingDialog = nullptr;
135-
};
138+
};

Source/SampleGame426/Public/UI/Marketplace/SearchStacksWidget.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ enum class ESearchStacks_SortCategories : uint8
1515
Price
1616
};
1717

18-
1918
/**
2019
* @class USearchStacksWidget
2120
* @ingroup Marketplace
@@ -33,15 +32,15 @@ class SAMPLEGAME426_API USearchStacksWidget : public UActivatableWidgetWithContr
3332
/* UActivatableWidgetWithControlPanels interface */
3433
virtual void Refresh() override;
3534
/* UActivatableWidgetWithControlPanels interface */
36-
35+
3736
/**
3837
* Refreshes the item list in the marketplace search stacks widget. Overrides IItemListInterface::RefreshItemList.
3938
*
4039
* @param PageCursor An optional string representing the cursor for pagination.
4140
* If provided, the item list will be refreshed starting from the specified page cursor.
4241
*/
4342
virtual void RefreshItemList(TOptional<FString> PageCursor) override;
44-
43+
4544
// Get the currently selected item widget
4645
UItemWidget* GetSelectedItem() const { return SelectedItemWidget; }
4746

@@ -89,14 +88,18 @@ class SAMPLEGAME426_API USearchStacksWidget : public UActivatableWidgetWithContr
8988
UPROPERTY(EditAnywhere, Category = "Marketplace")
9089
TSoftClassPtr<class USearchStacksListingWidget> SearchStacksListingWidgetClass;
9190

92-
private:
91+
protected:
9392
ImmutablezkEVMAPI::APIPage PageCursors;
94-
UItemWidget* SelectedItemWidget = nullptr;
93+
94+
UPROPERTY(BlueprintReadOnly)
95+
TObjectPtr<UItemWidget> SelectedItemWidget;
96+
9597
UPROPERTY(Transient)
96-
UControlPanelButton* PreviousPageButton = nullptr;
98+
TObjectPtr<UControlPanelButton> PreviousPageButton;
99+
97100
UPROPERTY(Transient)
98-
UControlPanelButton* NextPageButton = nullptr;
101+
TObjectPtr<UControlPanelButton> NextPageButton;
102+
99103
UPROPERTY(Transient)
100-
UControlPanelButton* NFTInfoButton = nullptr;
101-
102-
};
104+
TObjectPtr<UControlPanelButton> NFTInfoButton;
105+
};

0 commit comments

Comments
 (0)