Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
4 changes: 3 additions & 1 deletion packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 26.1.3

* [swift][kotlin] Fixes crash that occurs when a object that is removed from the instance manager
calls to Dart.
* Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.

## 26.1.2
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/src/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'generator.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '26.1.2';
const String pigeonVersion = '26.1.3';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
12 changes: 12 additions & 0 deletions packages/pigeon/lib/src/kotlin/kotlin_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,18 @@ fun deepEquals(a: Any?, b: Any?): Boolean {
$errorClassName("ignore-calls-error", "Calls to Dart are being ignored.", "")))
return''');
},
addTrailingNewline: false,
);
indent.writeScoped(
' else if (!pigeonRegistrar.instanceManager.containsInstance(${classMemberNamePrefix}instanceArg)) {',
'}',
() {
indent.format('''
callback(
Result.failure(
$errorClassName("missing-instance-error", "Calling instance is not in the instance manager.", "")))
return''');
},
);
indent.writeln(
'val binaryMessenger = pigeonRegistrar.binaryMessenger',
Expand Down
21 changes: 20 additions & 1 deletion packages/pigeon/lib/src/swift/swift_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,26 @@ func deepHash${generatorOptions.fileSpecificClassNameComponent}(value: Any?, has
code: "ignore-calls-error",
message: "Calls to Dart are being ignored.", details: "")))
return''');
});
}, addTrailingNewline: false);

final String instanceArgName = _getSafeArgumentName(
0,
NamedType(name: 'pigeonInstance', type: apiAsTypeDeclaration),
);
indent.writeScoped(
' else if !pigeonRegistrar.instanceManager.containsInstance($instanceArgName as AnyObject) {',
'}',
() {
indent.format('''
completion(
.failure(
${_getErrorClassName(generatorOptions)}(
code: "missing-instance-error",
message: "Calling instance is not in the instance manager.", details: "")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Calling instance is not...

Should it be calling instance [instance name]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[instanceName] would always be pigeonInstanceArg and wouldn't be that helpful. But the error message probably would be more helpful if I added the class and method name here, so I'll add that.

return''');
},
);

indent.writeln(
'let binaryMessenger = pigeonRegistrar.binaryMessenger',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ProxyApiInterface

@RequiresApi(25) class ClassWithApiRequirement

class ProxyApiRegistrar(binaryMessenger: BinaryMessenger) :
open class ProxyApiRegistrar(binaryMessenger: BinaryMessenger) :
ProxyApiTestsPigeonProxyApiRegistrar(binaryMessenger) {
override fun getPigeonApiProxyApiTestClass(): PigeonApiProxyApiTestClass {
return ProxyApiTestClassApi(this)
Expand Down
Loading