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
  • Loading branch information
Chris Yang committed Nov 6, 2023
commit 68da8984a938219e4481dda222760182f871e356
7 changes: 4 additions & 3 deletions fml/platform/darwin/scoped_nsobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class scoped_nsprotocol
: ScopedTypeRef<NST, Traits>(that_as_subclass) {}

scoped_nsprotocol(scoped_nsprotocol<NST>&& that)
: ScopedTypeRef<NST, Traits>(that) {}
: ScopedTypeRef<NST, Traits>(std::move(that)) {}

scoped_nsprotocol& operator=(const scoped_nsprotocol<NST>& that) {
ScopedTypeRef<NST, Traits>::operator=(that);
Expand Down Expand Up @@ -168,7 +168,7 @@ class scoped_nsobject : public scoped_nsprotocol<NST*> {
: scoped_nsprotocol<NST*>(that_as_subclass) {}

scoped_nsobject(scoped_nsobject<NST>&& that)
: scoped_nsprotocol<NST*>(that) {}
: scoped_nsprotocol<NST*>(std::move(that)) {}

scoped_nsobject& operator=(const scoped_nsobject<NST>& that) {
scoped_nsprotocol<NST*>::operator=(that);
Expand Down Expand Up @@ -216,7 +216,8 @@ class scoped_nsobject<id> : public scoped_nsprotocol<id> {
explicit scoped_nsobject(const scoped_nsobject<NSR>& that_as_subclass)
: scoped_nsprotocol<id>(that_as_subclass) {}

scoped_nsobject(scoped_nsobject<id>&& that) : scoped_nsprotocol<id>(that) {}
scoped_nsobject(scoped_nsobject<id>&& that)
: scoped_nsprotocol<id>(std::move(that)) {}

scoped_nsobject& operator=(const scoped_nsobject<id>& that) {
scoped_nsprotocol<id>::operator=(that);
Expand Down
6 changes: 6 additions & 0 deletions fml/platform/darwin/scoped_nsobject_unittests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
ASSERT_EQ(3u, [p1 retainCount]);
}
ASSERT_EQ(2u, [p1 retainCount]);

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

// Instantiating scoped_nsobject<> with T=NSAutoreleasePool should trip a
Expand Down