I did this to fix this error for me;
The action just previous to the start of this error;
I was installing a plugin to Unreal Engine 5.6.0 called 3Dconnexion Plugin for Unreal Editor. During the installation the Epic Games Launcher crashed with the following message and would not restart after many attempts.
Assertion failed: IsValid() [File:D:\build++Portal\Sync\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 890]
I navigated to the file and opened with MS Visual Studio 2022 and scrolled down to line #890 and found the following code;
886 /**
887 * Aliasing constructor used to create a shared pointer which shares its reference count with
888 * another shared object, but pointing to a different object, typically a subobject.
889 *
890 * @param OtherSharedRef The shared reference whose reference count should be shared.
891 * @param InObject The object pointer to use (instead of the incoming shared pointer’s object)
892 /
893 template
894 FORCEINLINE TSharedPtr( TSharedRef< OtherType, Mode > const& OtherSharedRef, ObjectType InObject )
895 : Object( InObject )
896 , SharedReferenceCount( OtherSharedRef.SharedReferenceCount )
897 {
898 }
I copied these lines of code into an AI code debug site and it came back with;
START
Debugging the TSharedPtr Constructor
Code Summary
The provided code snippet defines a constructor for a template class TSharedPtr
, which is designed to create a shared pointer that shares its reference count with another shared object. This is particularly useful when dealing with subobjects.
Problem
Upon reviewing the code, there is a potential issue with the constructor’s initialization list. Specifically, the SharedReferenceCount
member is being initialized directly from OtherSharedRef.SharedReferenceCount
, which may not be the intended behavior if SharedReferenceCount
is not properly defined or if it does not exist in the context of TSharedPtr
.
Cause
The root cause of the problem lies in the assumption that SharedReferenceCount
is a valid member of the TSharedPtr
class. If SharedReferenceCount
is not defined within the class, or if it is not intended to be initialized in this manner, it will lead to compilation errors or undefined behavior.
Solution
To resolve this issue, ensure that SharedReferenceCount
is a valid member of the TSharedPtr
class. If it is intended to be a reference count, it should be properly defined and initialized. Here is a corrected version of the constructor, assuming SharedReferenceCount
is a member of the class:
END
SUGGESTED CODE FIX
template
FORCEINLINE TSharedPtr(TSharedRef<OtherType, Mode> const& OtherSharedRef, ObjectType* InObject)
: Object(InObject)
, SharedReferenceCount(OtherSharedRef.GetReferenceCount()) // Assuming GetReferenceCount() is a valid method
{
}
END
ANALYSIS AND SUMMARY
I then compared the lines of code with each one of the suggested correction and the original and discovered line 896 was missing a set of Parentheses at the end of code just before the closing parenthese. So I added them, saved the changes and Unreal Engine Launcher is working good.
886 /**
887 * Aliasing constructor used to create a shared pointer which shares its reference count with
888 * another shared object, but pointing to a different object, typically a subobject.
889 *
890 * @param OtherSharedRef The shared reference whose reference count should be shared.
891 * @param InObject The object pointer to use (instead of the incoming shared pointer’s object)
892 /
893 template
894 FORCEINLINE TSharedPtr( TSharedRef< OtherType, Mode > const& OtherSharedRef, ObjectType InObject )
895 : Object( InObject )
896 , SharedReferenceCount( OtherSharedRef.SharedReferenceCount () )
897 {
898 }
A final note;
I did another check as I had removed the Parentheses then saved and restarted Unreal Engine Launcher and it worked fine with no issues after installing the named plugin.
So to Summarize, I think the error was created when the plugin installation was being installed and the launcher crashed before completing the install which wouldn’t allow the Launcher to restart so after adding the Parentheses and then finishing the install, the launcher doesn’t require that line of code so no errors. I’m leaving the Parentheses in the code. I was successful to install the plugin in 5.6.0 with no further issues.
HOPE THIS HELPS SOMEONE!