This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 2 files changed +9
-1
lines changed 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 6
6
#define FLUTTER_FML_PLATFORM_DARWIN_SCOPED_NSOBJECT_H_
7
7
8
8
#include < type_traits>
9
+ #include < utility>
9
10
10
11
// Include NSObject.h directly because Foundation.h pulls in many dependencies.
11
12
// (Approx 100k lines of code versus 1.5k for NSObject.h). scoped_nsobject gets
Original file line number Diff line number Diff line change 10
10
11
11
namespace {
12
12
13
+ // This is to suppress the bugprone-use-after-move warning.
14
+ // This strategy is recommanded here:
15
+ // https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html#silencing-erroneous-warnings
16
+ template <class T >
17
+ void IS_INITIALIZED (T&) {}
18
+
13
19
TEST (ScopedNSObjectTest, ScopedNSObject) {
14
20
fml::scoped_nsobject<NSObject > p1 ([[NSObject alloc ] init ]);
15
21
ASSERT_TRUE (p1.get ());
51
57
}
52
58
ASSERT_EQ (2u , [p1 retainCount ]);
53
59
54
- fml::scoped_nsobject<NSObject > p7 ([NSObject new ]);
60
+ fml::scoped_nsobject<NSObject > p7 ([[ NSObject alloc ] init ]);
55
61
fml::scoped_nsobject<NSObject > p8 (std::move (p7));
56
62
ASSERT_TRUE (p8);
57
63
ASSERT_EQ (1u , [p8 retainCount ]);
64
+ IS_INITIALIZED (p7);
58
65
ASSERT_FALSE (p7.get ());
59
66
}
60
67
You can’t perform that action at this time.
0 commit comments