Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Apr 4, 2022

The crash is described in flutter/flutter#101234

The fix is to make sure the argument is a String before propagating the value to the paste board object.
This PR also fixed an existing false positive test. The testHasStrings test passes because we were checking if an object is nil instead of checking the actual bool value. The test should have failed because the wrong method channel name was used.

Fixes: flutter/flutter#101234

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Comment on lines 40 to 44
__block bool value;
FlutterResult result = ^(id result) {
called = true;
value = result[@"value"];
value = [result[@"value"] boolValue];
};
Copy link
Member

@jmagman jmagman Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __block pattern that was here and you copied is kind of hard to read imo since the assertion about the value is after the method call, how about:

  XCTestExpectation *hasStringsExpectation = [self expectationWithDescription:@"hasStrings"];
  FlutterResult result = ^(id result) {
    XCTAssertTrue(result[@"value"]);
    [hasStringsExpectation fulfill];
  };
...
  [self waitForExpectationsWithTimeout:1 handler:nil];

At the least these should be BOOL and not bool and XCTAssertTrue(called);

Chris Yang added 2 commits April 4, 2022 15:22
@cyanglaz
Copy link
Contributor Author

cyanglaz commented Apr 4, 2022

@jmagman Updated. PTAL

@cyanglaz cyanglaz requested a review from jmagman April 4, 2022 22:22
@"PointerData.time_stamp should be equal to NSProcessInfo.systemUptime");
}
@end
//// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing you didn't mean to check this in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Chris Yang added 2 commits April 4, 2022 16:23
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cyanglaz cyanglaz added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 4, 2022
@fluttergithubbot fluttergithubbot merged commit 1b3e9dc into flutter:main Apr 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 5, 2022
@cyanglaz cyanglaz deleted the copy_paste_crash branch April 5, 2022 20:56
zanderso pushed a commit to flutter/flutter that referenced this pull request Apr 5, 2022
* 9b3117a Create `ImageFilter.dilate`/`ImageFilter.erode` (flutter/engine#32334)

* 92a6ade Roll Fuchsia Mac SDK from m_-rjFvCk... to hJaq9O7XI... (flutter/engine#32402)

* 31fd1bb Roll Fuchsia Linux SDK from 5abhmXb9Q... to WdxX5Sqix... (flutter/engine#32403)

* f088801 Roll Skia from 5215ec1ab9cd to fd9c66e18030 (1 revision) (flutter/engine#32406)

* ac21195 Fix inconsistent enum/class private member naming (flutter/engine#32409)

* 75e7cfd Fix deltas when selection is active and composing begins on MacOS (flutter/engine#32412)

* 7e5989b Fix SemanticsAction naming consistency (flutter/engine#32411)

* 1b3e9dc Fix a crash when setting clipboardData to null on iOS (flutter/engine#32413)

* ef50b28 Roll Fuchsia Linux SDK from WdxX5Sqix... to PmeDIogNb... (flutter/engine#32422)

* b48d65e Roll Fuchsia Mac SDK from hJaq9O7XI... to WBAQhRswX... (flutter/engine#32423)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-ios waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] App crashes when clipboard set data with null
3 participants