Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
include utility
fake init to supress warning
  • Loading branch information
Chris Yang committed Nov 6, 2023
commit cfccb751aff97555f1518aaa6b4758277d12ed74
1 change: 1 addition & 0 deletions fml/platform/darwin/scoped_nsobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_FML_PLATFORM_DARWIN_SCOPED_NSOBJECT_H_

#include <type_traits>
#include <utility>

// Include NSObject.h directly because Foundation.h pulls in many dependencies.
// (Approx 100k lines of code versus 1.5k for NSObject.h). scoped_nsobject gets
Expand Down
9 changes: 8 additions & 1 deletion fml/platform/darwin/scoped_nsobject_unittests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

namespace {

// This is to suppress the bugprone-use-after-move warning.
// This strategy is recommanded here:
// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html#silencing-erroneous-warnings
template <class T>
void IS_INITIALIZED(T&) {}

TEST(ScopedNSObjectTest, ScopedNSObject) {
fml::scoped_nsobject<NSObject> p1([[NSObject alloc] init]);
ASSERT_TRUE(p1.get());
Expand Down Expand Up @@ -51,10 +57,11 @@
}
ASSERT_EQ(2u, [p1 retainCount]);

fml::scoped_nsobject<NSObject> p7([NSObject new]);
fml::scoped_nsobject<NSObject> p7([[NSObject alloc] init]);
fml::scoped_nsobject<NSObject> p8(std::move(p7));
ASSERT_TRUE(p8);
ASSERT_EQ(1u, [p8 retainCount]);
IS_INITIALIZED(p7);
ASSERT_FALSE(p7.get());
}

Expand Down