Skip to content

Commit

Permalink
Merge pull request #125 from NuiCpp/fix/scope_exit_rule_of_five
Browse files Browse the repository at this point in the history
Made scope exit class abide rule of 5.
  • Loading branch information
5cript authored Nov 23, 2024
2 parents 03f16e4 + e21953c commit 873ad20
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/dependencies/interval_tree.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
option(NUI_FETCH_INTERVAL_TREE "Fetch interval tree" ON)
set(NUI_INTERVAL_TREE_GIT_REPOSITORY "https://github.com/5cript/interval-tree.git" CACHE STRING "interval tree git repository")
set(NUI_INTERVAL_TREE_GIT_TAG "v2.2.4" CACHE STRING "interval tree git tag")
set(NUI_INTERVAL_TREE_GIT_TAG "v2.3.2" CACHE STRING "interval tree git tag")

if(NUI_FETCH_INTERVAL_TREE)
include(FetchContent)
Expand Down
2 changes: 1 addition & 1 deletion cmake/dependencies/roar.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
option(NUI_FETCH_ROAR "Fetch roar" ON)
set(NUI_ROAR_REPOSITORY "https://github.com/5cript/roar.git" CACHE STRING "roar repository")
set(NUI_ROAR_TAG "2781a88fcd1fce9af1a697673e26fd3ad55817e9" CACHE STRING "roar tag")
set(NUI_ROAR_TAG "a8eda5bc6d4800a8f389a3007e793eb233ea6192" CACHE STRING "roar tag")

if(NUI_FETCH_ROAR)
include(FetchContent)
Expand Down
2 changes: 1 addition & 1 deletion nui/include/nui/event_system/range_event_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace Nui
}
friend bool operator==(RangeStateInterval const& lhs, RangeStateInterval const& rhs)
{
return lhs.start_ == rhs.start_ && lhs.end_ == rhs.end_ && lhs.type_ == rhs.type_;
return lhs.low_ == rhs.low_ && lhs.high_ == rhs.high_;
}
friend bool operator!=(RangeStateInterval const& lhs, RangeStateInterval const& rhs)
{
Expand Down
21 changes: 19 additions & 2 deletions nui/include/nui/utility/scope_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,28 @@ namespace Nui
{}
~ScopeExit()
{
onExit_();
if (onExit_)
onExit_();
}
ScopeExit(ScopeExit&& other)
: onExit_(std::move(other.onExit_))
{
other.onExit_ = {};
}
ScopeExit& operator=(ScopeExit&& other)
{
if (this != &other)
{
onExit_ = std::move(other.onExit_);
other.onExit_ = {};
}
return *this;
}
ScopeExit(const ScopeExit&) = delete;
ScopeExit& operator=(const ScopeExit&) = delete;
void disarm()
{
onExit_ = [] {};
onExit_ = {};
}

private:
Expand Down

0 comments on commit 873ad20

Please sign in to comment.