From 0be1987e1a7f71ca468644be58984b64908c7941 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 1 Nov 2024 05:05:11 -0700 Subject: [PATCH] fml: Delete weak_nsobject.h,mm (flutter/engine#56289) These classes are no longer necessary now that the entire codebase has been migrated to ARC. Issue: https://github.com/flutter/flutter/issues/137801 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../flutter/ci/licenses_golden/excluded_files | 2 - .../ci/licenses_golden/licenses_flutter | 4 - engine/src/flutter/fml/BUILD.gn | 12 +- .../fml/platform/darwin/weak_nsobject.h | 282 ------------------ .../fml/platform/darwin/weak_nsobject.mm | 67 ----- .../darwin/weak_nsobject_arc_unittests.mm | 121 -------- .../darwin/weak_nsobject_unittests.mm | 95 ------ .../framework/Source/FlutterPlatformPlugin.h | 1 - .../Source/FlutterPlatformPluginTest.mm | 1 - 9 files changed, 2 insertions(+), 583 deletions(-) delete mode 100644 engine/src/flutter/fml/platform/darwin/weak_nsobject.h delete mode 100644 engine/src/flutter/fml/platform/darwin/weak_nsobject.mm delete mode 100644 engine/src/flutter/fml/platform/darwin/weak_nsobject_arc_unittests.mm delete mode 100644 engine/src/flutter/fml/platform/darwin/weak_nsobject_unittests.mm diff --git a/engine/src/flutter/ci/licenses_golden/excluded_files b/engine/src/flutter/ci/licenses_golden/excluded_files index 0392730b99..df0d4e3655 100644 --- a/engine/src/flutter/ci/licenses_golden/excluded_files +++ b/engine/src/flutter/ci/licenses_golden/excluded_files @@ -109,8 +109,6 @@ ../../../flutter/fml/platform/darwin/scoped_nsobject_arc_unittests.mm ../../../flutter/fml/platform/darwin/scoped_nsobject_unittests.mm ../../../flutter/fml/platform/darwin/string_range_sanitization_unittests.mm -../../../flutter/fml/platform/darwin/weak_nsobject_arc_unittests.mm -../../../flutter/fml/platform/darwin/weak_nsobject_unittests.mm ../../../flutter/fml/platform/fuchsia/log_interest_listener_unittests.cc ../../../flutter/fml/platform/win/file_win_unittests.cc ../../../flutter/fml/platform/win/wstring_conversion_unittests.cc diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 3f2f1e42f9..75524526fd 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -42739,8 +42739,6 @@ ORIGIN: ../../../flutter/fml/platform/darwin/scoped_policy.h + ../../../flutter/ ORIGIN: ../../../flutter/fml/platform/darwin/scoped_typeref.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/fml/platform/darwin/string_range_sanitization.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/fml/platform/darwin/weak_nsobject.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/fml/platform/darwin/weak_nsobject.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/fml/platform/fuchsia/log_interest_listener.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/fml/platform/fuchsia/log_interest_listener.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/fml/platform/fuchsia/log_state.cc + ../../../flutter/LICENSE @@ -45601,8 +45599,6 @@ FILE: ../../../flutter/fml/platform/darwin/scoped_policy.h FILE: ../../../flutter/fml/platform/darwin/scoped_typeref.h FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.h FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm -FILE: ../../../flutter/fml/platform/darwin/weak_nsobject.h -FILE: ../../../flutter/fml/platform/darwin/weak_nsobject.mm FILE: ../../../flutter/fml/platform/fuchsia/log_interest_listener.cc FILE: ../../../flutter/fml/platform/fuchsia/log_interest_listener.h FILE: ../../../flutter/fml/platform/fuchsia/log_state.cc diff --git a/engine/src/flutter/fml/BUILD.gn b/engine/src/flutter/fml/BUILD.gn index 2dc48033fb..182989d884 100644 --- a/engine/src/flutter/fml/BUILD.gn +++ b/engine/src/flutter/fml/BUILD.gn @@ -162,8 +162,6 @@ source_set("fml") { "platform/darwin/scoped_typeref.h", "platform/darwin/string_range_sanitization.h", "platform/darwin/string_range_sanitization.mm", - "platform/darwin/weak_nsobject.h", - "platform/darwin/weak_nsobject.mm", ] frameworks = [ "Foundation.framework" ] @@ -377,10 +375,7 @@ if (enable_unittests) { } if (is_mac || is_ios) { - sources += [ - "platform/darwin/scoped_nsobject_unittests.mm", - "platform/darwin/weak_nsobject_unittests.mm", - ] + sources += [ "platform/darwin/scoped_nsobject_unittests.mm" ] } if (is_fuchsia) { @@ -418,10 +413,7 @@ if (enable_unittests) { testonly = true if (is_mac || is_ios) { cflags_objcc = flutter_cflags_objc_arc - sources = [ - "platform/darwin/scoped_nsobject_arc_unittests.mm", - "platform/darwin/weak_nsobject_arc_unittests.mm", - ] + sources = [ "platform/darwin/scoped_nsobject_arc_unittests.mm" ] } deps = [ diff --git a/engine/src/flutter/fml/platform/darwin/weak_nsobject.h b/engine/src/flutter/fml/platform/darwin/weak_nsobject.h deleted file mode 100644 index 92120e18eb..0000000000 --- a/engine/src/flutter/fml/platform/darwin/weak_nsobject.h +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_FML_PLATFORM_DARWIN_WEAK_NSOBJECT_H_ -#define FLUTTER_FML_PLATFORM_DARWIN_WEAK_NSOBJECT_H_ - -#import -#import - -#include - -#include - -#include "flutter/fml/logging.h" -#include "flutter/fml/memory/ref_counted.h" -#include "flutter/fml/memory/ref_ptr.h" -#include "flutter/fml/memory/thread_checker.h" - -namespace debug { -struct DebugThreadChecker { - FML_DECLARE_THREAD_CHECKER(checker); -}; -} // namespace debug - -// WeakNSObject<> is patterned after scoped_nsobject<>, but instead of -// maintaining ownership of an NSObject subclass object, it will nil itself out -// when the object is deallocated. -// -// WeakNSProtocol<> has the same behavior as WeakNSObject, but can be used -// with protocols. -// -// Example usage (fml::WeakNSObject): -// WeakNSObjectFactory factory([[Foo alloc] init]); -// WeakNSObject weak_foo; // No pointer -// weak_foo = factory.GetWeakNSObject() // Now a weak reference is kept. -// [weak_foo description]; // Returns [foo description]. -// foo.reset(); // The reference is released. -// [weak_foo description]; // Returns nil, as weak_foo is pointing to nil. -// -// -// Implementation wise a WeakNSObject keeps a reference to a refcounted -// WeakContainer. There is one unique instance of a WeakContainer per watched -// NSObject, this relationship is maintained via the ObjectiveC associated -// object API, indirectly via an ObjectiveC CRBWeakNSProtocolSentinel class. -// -// Threading restrictions: -// - Several WeakNSObject pointing to the same underlying object must all be -// created and dereferenced on the same thread; -// - thread safety is enforced by the implementation, except: -// - it is allowed to destroy a WeakNSObject on any thread; -// - the implementation assumes that the tracked object will be released on the -// same thread that the WeakNSObject is created on. -// -// fml specifics: -// WeakNSObjects can only originate from a |WeakNSObjectFactory| (see below), though WeakNSObjects -// are copyable and movable. -// -// WeakNSObjects are not in general thread-safe. They may only be *used* on -// a single thread, namely the same thread as the "originating" -// |WeakNSObjectFactory| (which can invalidate the WeakNSObjects that it -// generates). -// -// However, WeakNSObject may be passed to other threads, reset on other -// threads, or destroyed on other threads. They may also be reassigned on -// other threads (in which case they should then only be used on the thread -// corresponding to the new "originating" |WeakNSObjectFactory|). -namespace fml { - -// Forward declaration, so |WeakNSObject| can friend it. -template -class WeakNSObjectFactory; - -// WeakContainer keeps a weak pointer to an object and clears it when it -// receives nullify() from the object's sentinel. -class WeakContainer : public fml::RefCountedThreadSafe { - public: - explicit WeakContainer(id object, const debug::DebugThreadChecker& checker); - - id object() { - CheckThreadSafety(); - return object_; - } - - void nullify() { object_ = nil; } - - private: - friend fml::RefCountedThreadSafe; - ~WeakContainer(); - - __unsafe_unretained id object_; - - void CheckThreadSafety() const { FML_DCHECK_CREATION_THREAD_IS_CURRENT(checker_.checker); } - -// checker_ is unused in non-unopt mode. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-private-field" - debug::DebugThreadChecker checker_; -#pragma clang diagnostic pop -}; - -} // namespace fml - -// Sentinel for observing the object contained in the weak pointer. The object -// will be deleted when the weak object is deleted and will notify its -// container. -@interface CRBWeakNSProtocolSentinel : NSObject -// Return the only associated container for this object. There can be only one. -// Will return null if object is nil . -+ (fml::RefPtr)containerForObject:(id)object - threadChecker:(debug::DebugThreadChecker)checker; -@end - -namespace fml { - -// Base class for all WeakNSObject derivatives. -template -class WeakNSProtocol { - public: - WeakNSProtocol() = default; - - // A WeakNSProtocol object can be copied on one thread and used on - // another. - WeakNSProtocol(const WeakNSProtocol& that) - : container_(that.container_), checker_(that.checker_) {} - - ~WeakNSProtocol() = default; - - void reset() { - container_ = [CRBWeakNSProtocolSentinel containerForObject:nil threadChecker:checker_]; - } - - NST get() const { - CheckThreadSafety(); - if (!container_.get()) { - return nil; - } - return container_->object(); - } - - WeakNSProtocol& operator=(const WeakNSProtocol& that) { - // A WeakNSProtocol object can be copied on one thread and used on - // another. - container_ = that.container_; - checker_ = that.checker_; - return *this; - } - - bool operator==(NST that) const { - CheckThreadSafety(); - return get() == that; - } - - bool operator!=(NST that) const { - CheckThreadSafety(); - return get() != that; - } - - // This appears to be intentional to allow truthiness? - // NOLINTNEXTLINE(google-explicit-constructor) - operator NST() const { - CheckThreadSafety(); - return get(); - } - - protected: - friend class WeakNSObjectFactory; - - explicit WeakNSProtocol(RefPtr container, - const debug::DebugThreadChecker& checker) - : container_(std::move(container)), checker_(checker) {} - - // Refecounted reference to the container tracking the ObjectiveC object this - // class encapsulates. - RefPtr container_; - void CheckThreadSafety() const { FML_DCHECK_CREATION_THREAD_IS_CURRENT(checker_.checker); } - - debug::DebugThreadChecker checker_; -}; - -// Free functions -template -bool operator==(NST p1, const WeakNSProtocol& p2) { - return p1 == p2.get(); -} - -template -bool operator!=(NST p1, const WeakNSProtocol& p2) { - return p1 != p2.get(); -} - -template -class WeakNSObject : public WeakNSProtocol { - public: - WeakNSObject() = default; - WeakNSObject(const WeakNSObject& that) : WeakNSProtocol(that) {} - - WeakNSObject& operator=(const WeakNSObject& that) { - WeakNSProtocol::operator=(that); - return *this; - } - - private: - friend class WeakNSObjectFactory; - - explicit WeakNSObject(RefPtr container, debug::DebugThreadChecker checker) - : WeakNSProtocol(container, checker) {} -}; - -// Specialization to make WeakNSObject work. -template <> -class WeakNSObject : public WeakNSProtocol { - public: - WeakNSObject() = default; - WeakNSObject(const WeakNSObject& that) : WeakNSProtocol(that) {} - - WeakNSObject& operator=(const WeakNSObject& that) { - WeakNSProtocol::operator=(that); - return *this; - } - - private: - friend class WeakNSObjectFactory; - - explicit WeakNSObject(const RefPtr& container, - const debug::DebugThreadChecker& checker) - : WeakNSProtocol(container, checker) {} -}; - -// Class that produces (valid) |WeakNSObject|s. Typically, this is used as a -// member variable of |NST| (preferably the last one -- see below), and |NST|'s -// methods control how WeakNSObjects to it are vended. This class is not -// thread-safe, and should only be created, destroyed and used on a single -// thread. -// -// Example: -// -// ```objc -// @implementation Controller { -// std::unique_ptr> _weakFactory; -// } -// -// - (instancetype)init { -// self = [super init]; -// _weakFactory = std::make_unique>(self) -// } - -// - (fml::WeakNSObject) { -// return _weakFactory->GetWeakNSObject() -// } -// -// @end -// ``` -template -class WeakNSObjectFactory { - public: - explicit WeakNSObjectFactory(NST* object) { - FML_DCHECK(object); - container_ = [CRBWeakNSProtocolSentinel containerForObject:object threadChecker:checker_]; - } - - ~WeakNSObjectFactory() { CheckThreadSafety(); } - - // Gets a new weak pointer, which will be valid until this object is - // destroyed.e - WeakNSObject GetWeakNSObject() const { return WeakNSObject(container_, checker_); } - - private: - // Refecounted reference to the container tracking the ObjectiveC object this - // class encapsulates. - RefPtr container_; - - void CheckThreadSafety() const { FML_DCHECK_CREATION_THREAD_IS_CURRENT(checker_.checker); } - - debug::DebugThreadChecker checker_; - - FML_DISALLOW_COPY_AND_ASSIGN(WeakNSObjectFactory); -}; - -} // namespace fml - -#endif // FLUTTER_FML_PLATFORM_DARWIN_WEAK_NSOBJECT_H_ diff --git a/engine/src/flutter/fml/platform/darwin/weak_nsobject.mm b/engine/src/flutter/fml/platform/darwin/weak_nsobject.mm deleted file mode 100644 index e255515caf..0000000000 --- a/engine/src/flutter/fml/platform/darwin/weak_nsobject.mm +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/fml/platform/darwin/weak_nsobject.h" -#include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h" -#include "flutter/fml/platform/darwin/scoped_nsobject.h" - -namespace { -// The key needed by objc_setAssociatedObject. -char sentinelObserverKey_; -} // namespace - -namespace fml { - -WeakContainer::WeakContainer(id object, const debug::DebugThreadChecker& checker) - : object_(object), checker_(checker) {} - -WeakContainer::~WeakContainer() {} - -} // namespace fml - -@interface CRBWeakNSProtocolSentinel () -// Container to notify on dealloc. -@property(readonly, assign) fml::RefPtr container; -// Designed initializer. -- (id)initWithContainer:(fml::RefPtr)container; -@end - -@implementation CRBWeakNSProtocolSentinel - -+ (fml::RefPtr)containerForObject:(id)object - threadChecker:(debug::DebugThreadChecker)checker { - if (object == nil) { - return nullptr; - } - // The autoreleasePool is needed here as the call to objc_getAssociatedObject - // returns an autoreleased object which is better released sooner than later. - fml::ScopedNSAutoreleasePool pool; - CRBWeakNSProtocolSentinel* sentinel = objc_getAssociatedObject(object, &sentinelObserverKey_); - if (!sentinel) { - fml::scoped_nsobject newSentinel([[CRBWeakNSProtocolSentinel alloc] - initWithContainer:AdoptRef(new fml::WeakContainer(object, checker))]); - sentinel = newSentinel; - objc_setAssociatedObject(object, &sentinelObserverKey_, sentinel, OBJC_ASSOCIATION_RETAIN); - // The retain count is 2. One retain is due to the alloc, the other to the - // association with the weak object. - FML_DCHECK(2u == [sentinel retainCount]); - } - return [sentinel container]; -} - -- (id)initWithContainer:(fml::RefPtr)container { - FML_DCHECK(container.get()); - self = [super init]; - if (self) { - _container = container; - } - return self; -} - -- (void)dealloc { - _container->nullify(); - [super dealloc]; -} - -@end diff --git a/engine/src/flutter/fml/platform/darwin/weak_nsobject_arc_unittests.mm b/engine/src/flutter/fml/platform/darwin/weak_nsobject_arc_unittests.mm deleted file mode 100644 index 7e09b746d5..0000000000 --- a/engine/src/flutter/fml/platform/darwin/weak_nsobject_arc_unittests.mm +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/fml/message_loop.h" -#include "flutter/fml/platform/darwin/scoped_nsobject.h" -#include "flutter/fml/platform/darwin/weak_nsobject.h" -#include "flutter/fml/task_runner.h" -#include "flutter/fml/thread.h" -#include "gtest/gtest.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -namespace fml { -namespace { - -TEST(WeakNSObjectTestARC, WeakNSObject) { - scoped_nsobject p1; - WeakNSObject w1; - @autoreleasepool { - p1.reset(([[NSObject alloc] init])); - WeakNSObjectFactory factory(p1.get()); - w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - p1.reset(); - } - EXPECT_FALSE(w1); -} - -TEST(WeakNSObjectTestARC, MultipleWeakNSObject) { - scoped_nsobject p1; - WeakNSObject w1; - WeakNSObject w2; - @autoreleasepool { - p1.reset([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - w1 = factory.GetWeakNSObject(); - // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) - w2 = w1; - EXPECT_TRUE(w1); - EXPECT_TRUE(w2); - EXPECT_TRUE(w1.get() == w2.get()); - p1.reset(); - } - EXPECT_FALSE(w1); - EXPECT_FALSE(w2); -} - -TEST(WeakNSObjectTestARC, WeakNSObjectDies) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - { - WeakNSObject w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - } -} - -TEST(WeakNSObjectTestARC, WeakNSObjectReset) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - WeakNSObject w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - w1.reset(); - EXPECT_FALSE(w1); - EXPECT_TRUE(p1); - EXPECT_TRUE([p1 description]); -} - -TEST(WeakNSObjectTestARC, WeakNSObjectEmpty) { - scoped_nsobject p1; - WeakNSObject w1; - @autoreleasepool { - scoped_nsobject p1([[NSObject alloc] init]); - EXPECT_FALSE(w1); - WeakNSObjectFactory factory(p1.get()); - w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - p1.reset(); - } - EXPECT_FALSE(w1); -} - -TEST(WeakNSObjectTestARC, WeakNSObjectCopy) { - scoped_nsobject p1; - WeakNSObject w1; - WeakNSObject w2; - @autoreleasepool { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - w1 = factory.GetWeakNSObject(); - // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) - w2 = w1; - EXPECT_TRUE(w1); - EXPECT_TRUE(w2); - p1.reset(); - } - EXPECT_FALSE(w1); - EXPECT_FALSE(w2); -} - -TEST(WeakNSObjectTestARC, WeakNSObjectAssignment) { - scoped_nsobject p1; - WeakNSObject w1; - WeakNSObject w2; - @autoreleasepool { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - w1 = factory.GetWeakNSObject(); - // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) - w2 = w1; - EXPECT_TRUE(w1); - EXPECT_TRUE(w2); - p1.reset(); - } - EXPECT_FALSE(w1); - EXPECT_FALSE(w2); -} -} // namespace -} // namespace fml diff --git a/engine/src/flutter/fml/platform/darwin/weak_nsobject_unittests.mm b/engine/src/flutter/fml/platform/darwin/weak_nsobject_unittests.mm deleted file mode 100644 index 0b93cdf449..0000000000 --- a/engine/src/flutter/fml/platform/darwin/weak_nsobject_unittests.mm +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/fml/message_loop.h" -#include "flutter/fml/platform/darwin/scoped_nsobject.h" -#include "flutter/fml/platform/darwin/weak_nsobject.h" -#include "flutter/fml/task_runner.h" -#include "flutter/fml/thread.h" -#include "gtest/gtest.h" - -namespace fml { -namespace { - -TEST(WeakNSObjectTest, WeakNSObject) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - WeakNSObject w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - p1.reset(); - EXPECT_FALSE(w1); -} - -TEST(WeakNSObjectTest, MultipleWeakNSObject) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - WeakNSObject w1 = factory.GetWeakNSObject(); - // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) - WeakNSObject w2(w1); - EXPECT_TRUE(w1); - EXPECT_TRUE(w2); - EXPECT_TRUE(w1.get() == w2.get()); - p1.reset(); - EXPECT_FALSE(w1); - EXPECT_FALSE(w2); -} - -TEST(WeakNSObjectTest, WeakNSObjectDies) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - { - WeakNSObject w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - } -} - -TEST(WeakNSObjectTest, WeakNSObjectReset) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - WeakNSObject w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - w1.reset(); - EXPECT_FALSE(w1); - EXPECT_TRUE(p1); - EXPECT_TRUE([p1 description]); -} - -TEST(WeakNSObjectTest, WeakNSObjectEmpty) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObject w1; - EXPECT_FALSE(w1); - WeakNSObjectFactory factory(p1.get()); - w1 = factory.GetWeakNSObject(); - EXPECT_TRUE(w1); - p1.reset(); - EXPECT_FALSE(w1); -} - -TEST(WeakNSObjectTest, WeakNSObjectCopy) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - WeakNSObject w1 = factory.GetWeakNSObject(); - // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) - WeakNSObject w2(w1); - EXPECT_TRUE(w1); - EXPECT_TRUE(w2); - p1.reset(); - EXPECT_FALSE(w1); - EXPECT_FALSE(w2); -} - -TEST(WeakNSObjectTest, WeakNSObjectAssignment) { - scoped_nsobject p1([[NSObject alloc] init]); - WeakNSObjectFactory factory(p1.get()); - WeakNSObject w1 = factory.GetWeakNSObject(); - // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) - WeakNSObject w2 = w1; - EXPECT_TRUE(w1); - EXPECT_TRUE(w2); - p1.reset(); - EXPECT_FALSE(w1); - EXPECT_FALSE(w2); -} -} // namespace -} // namespace fml diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h index 71f79c2ba4..45fd69cddf 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h @@ -5,7 +5,6 @@ #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMPLUGIN_H_ #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMPLUGIN_H_ -#include "flutter/fml/platform/darwin/weak_nsobject.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h" #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h" diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm index b6259e120c..779a2158c5 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm @@ -5,7 +5,6 @@ #import #import -#import "flutter/fml/platform/darwin/weak_nsobject.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"