diff --git a/Source/ImGui/Private/ImGuiContextManager.cpp b/Source/ImGui/Private/ImGuiContextManager.cpp index 4d5b33f..45dbf67 100644 --- a/Source/ImGui/Private/ImGuiContextManager.cpp +++ b/Source/ImGui/Private/ImGuiContextManager.cpp @@ -5,7 +5,6 @@ #include "ImGuiDelegatesContainer.h" #include "ImGuiImplementation.h" #include "ImGuiModuleSettings.h" -#include "Utilities/ScopeGuards.h" #include "Utilities/WorldContext.h" #include "Utilities/WorldContextIndex.h" diff --git a/Source/ImGui/Private/Utilities/ScopeGuards.h b/Source/ImGui/Private/Utilities/ScopeGuards.h deleted file mode 100644 index 2b0d962..0000000 --- a/Source/ImGui/Private/Utilities/ScopeGuards.h +++ /dev/null @@ -1,58 +0,0 @@ -// Distributed under the MIT License (MIT) (see accompanying LICENSE file) - -#pragma once - -namespace ScopeGuards -{ - // Saves snapshot of the object state and restores it during destruction. - template - class TStateSaver - { - public: - - // Constructor taking target object in state that we want to save. - TStateSaver(T& Target) - : Ptr(&Target) - , Value(Target) - { - } - - // Move constructor allowing to transfer state out of scope. - TStateSaver(TStateSaver&& Other) - : Ptr(Other.Ptr) - , Value(MoveTemp(Other.Value)) - { - // Release responsibility from the other object (std::exchange currently not supported by all platforms). - Other.Ptr = nullptr; - } - - // Non-assignable to enforce acquisition on construction. - TStateSaver& operator=(TStateSaver&&) = delete; - - // Non-copyable. - TStateSaver(const TStateSaver&) = delete; - TStateSaver& operator=(const TStateSaver&) = delete; - - ~TStateSaver() - { - if (Ptr) - { - *Ptr = Value; - } - } - - private: - - T* Ptr; - T Value; - }; - - // Create a state saver for target object. Unless saver is moved, state will be restored at the end of scope. - // @param Target - Target object in state that we want to save - // @returns State saver that unless moved, will restore target's state during scope exit - template - TStateSaver MakeStateSaver(T& Target) - { - return TStateSaver{ Target }; - } -} diff --git a/Source/ImGui/Private/Widgets/SImGuiWidget.cpp b/Source/ImGui/Private/Widgets/SImGuiWidget.cpp index a715e83..941fcd2 100644 --- a/Source/ImGui/Private/Widgets/SImGuiWidget.cpp +++ b/Source/ImGui/Private/Widgets/SImGuiWidget.cpp @@ -12,7 +12,6 @@ #include "ImGuiModuleSettings.h" #include "TextureManager.h" #include "Utilities/Arrays.h" -#include "Utilities/ScopeGuards.h" #include "VersionCompatibility.h" #include @@ -647,10 +646,6 @@ int32 SImGuiWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeo { #if ENGINE_COMPATIBILITY_LEGACY_CLIPPING_API DrawList.CopyVertexData(VertexBuffer, ImGuiToScreen, VertexClippingRect); - - // Get access to the Slate scissor rectangle defined in Slate Core API, so we can customize elements drawing. - extern SLATECORE_API TOptional GSlateScissorRect; - auto GSlateScissorRectSaver = ScopeGuards::MakeStateSaver(GSlateScissorRect); #else DrawList.CopyVertexData(VertexBuffer, ImGuiToScreen); #endif // ENGINE_COMPATIBILITY_LEGACY_CLIPPING_API @@ -672,7 +667,9 @@ int32 SImGuiWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeo const FSlateRect ClippingRect = DrawCommand.ClippingRect.IntersectionWith(MyClippingRect); #if ENGINE_COMPATIBILITY_LEGACY_CLIPPING_API - GSlateScissorRect = FShortRect{ ClippingRect }; + // Get access to the Slate scissor rectangle defined in Slate Core API, so we can customize elements drawing. + extern SLATECORE_API TOptional GSlateScissorRect; + TGuardValue> GSlateScissorRecGuard(GSlateScissorRect, FShortRect{ ClippingRect }); #else OutDrawElements.PushClip(FSlateClippingZone{ ClippingRect }); #endif // ENGINE_COMPATIBILITY_LEGACY_CLIPPING_API