Skip to content

Commit

Permalink
Use SetNum EAllowShrinking (UE 5.5 compatibility) (#38)
Browse files Browse the repository at this point in the history
* [SetNum/SetNumUninitialized]
    * Fixes for deprication warnings with update to 5.5.2 (5.5.1 also?) messages
    * Changes bool param for allowing shrinking to enum EAllowShrinking

* Wrapped changes in pre-processor blocks to satisfy UE4.?? compatibility

* Using provided macros to do the testing

* Switched version to 5.4 as that was the release version when this
deprecation change went through in the engine.

* Use custom define ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

---------

Co-authored-by: Timi Ornik <[email protected]>
  • Loading branch information
ericwomer and jonpas authored Feb 2, 2025
1 parent 2f81668 commit 52b6365
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/ImGui/Private/ImGuiContextProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ void FImGuiContextProxy::UpdateDrawData(ImDrawData* DrawData)
{
if (DrawData && DrawData->CmdListsCount > 0)
{
#if ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING
DrawLists.SetNum(DrawData->CmdListsCount, false);
#else
DrawLists.SetNum(DrawData->CmdListsCount, EAllowShrinking::No);
#endif // ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

for (int Index = 0; Index < DrawData->CmdListsCount; Index++)
{
Expand Down
8 changes: 8 additions & 0 deletions Source/ImGui/Private/ImGuiDrawData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ void FImGuiDrawList::CopyVertexData(TArray<FSlateVertex>& OutVertexBuffer, const
#endif // ENGINE_COMPATIBILITY_LEGACY_CLIPPING_API
{
// Reset and reserve space in destination buffer.
#if ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING
OutVertexBuffer.SetNumUninitialized(ImGuiVertexBuffer.Size, false);
#else
OutVertexBuffer.SetNumUninitialized(ImGuiVertexBuffer.Size, EAllowShrinking::No);
#endif // ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

// Transform and copy vertex data.
for (int Idx = 0; Idx < ImGuiVertexBuffer.Size; Idx++)
Expand Down Expand Up @@ -44,7 +48,11 @@ void FImGuiDrawList::CopyVertexData(TArray<FSlateVertex>& OutVertexBuffer, const
void FImGuiDrawList::CopyIndexData(TArray<SlateIndex>& OutIndexBuffer, const int32 StartIndex, const int32 NumElements) const
{
// Reset buffer.
#if ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING
OutIndexBuffer.SetNumUninitialized(NumElements, false);
#else
OutIndexBuffer.SetNumUninitialized(NumElements, EAllowShrinking::No);
#endif // ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

// Copy elements (slow copy because of different sizes of ImDrawIdx and SlateIndex and because SlateIndex can
// have different size on different platforms).
Expand Down
3 changes: 3 additions & 0 deletions Source/ImGui/Private/VersionCompatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
#define ENGINE_COMPATIBILITY_LEGACY_KEY_AXIS_API BELOW_ENGINE_VERSION(4, 26)

#define ENGINE_COMPATIBILITY_LEGACY_VECTOR2F BELOW_ENGINE_VERSION(5, 0)

// Starting from version 5.4, bAllowShrinking is deprecated in favour of EAllowShrinking enum.
#define ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING BELOW_ENGINE_VERSION(5, 4)

0 comments on commit 52b6365

Please sign in to comment.