Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tizen_bundle, tizen_rpc_port] Fix token in finalizer to be different from value #638

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/tizen_bundle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Increase the minimum Flutter version to 3.3.
* Fix token in finalizer to be different from value.

## 0.1.1

Expand Down
11 changes: 6 additions & 5 deletions packages/tizen_bundle/lib/tizen_bundle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ class Bundle extends MapMixin<String, Object> {
/// Creates an empty [Bundle].
Bundle() {
_handle = tizen.bundle_create();
_finalizer.attach(this, this, detach: this);
_finalizer.attach(this, _handle, detach: this);
}

/// Creates a [Bundle] from the encoded bundle string.
Bundle.decode(String raw) {
_handle = tizen.bundle_decode(
raw.toNativeInt8().cast<UnsignedChar>(), raw.length);
_finalizer.attach(this, this, detach: this);
_finalizer.attach(this, _handle, detach: this);
}

/// Creates a copy of the given [bundle].
Bundle.fromBundle(Bundle bundle) {
_handle = tizen.bundle_dup(bundle._handle);
_finalizer.attach(this, this, detach: this);
_finalizer.attach(this, _handle, detach: this);
}

/// Creates a [Bundle] from the given [map].
Expand All @@ -44,8 +44,9 @@ class Bundle extends MapMixin<String, Object> {
}

late final Pointer<bundle> _handle;
static final Finalizer<Bundle> _finalizer =
Finalizer<Bundle>((Bundle bundle) => tizen.bundle_free(bundle._handle));
static final Finalizer<Pointer<bundle>> _finalizer =
Finalizer<Pointer<bundle>>(
(Pointer<bundle> bundle) => tizen.bundle_free(bundle));

static final List<String> _keys = <String>[];

Expand Down
4 changes: 4 additions & 0 deletions packages/tizen_rpc_port/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Fix token in finalizer to be different from value.

## 0.1.3

* Remove unnecessary `StreamHandlerError` implementation.
Expand Down
9 changes: 3 additions & 6 deletions packages/tizen_rpc_port/lib/src/proxy_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ abstract class ProxyBase {
return pProxy.value;
});

_finalizer.attach(this, this);
_finalizer.attach(this, _handle);
}

late final rpc_port_proxy_h _handle;

final Finalizer<ProxyBase> _finalizer =
Finalizer<ProxyBase>((ProxyBase proxy) {
proxy._streamSubscription?.cancel();
tizen.rpc_port_proxy_destroy(proxy._handle);
});
final Finalizer<rpc_port_proxy_h> _finalizer = Finalizer<rpc_port_proxy_h>(
(rpc_port_proxy_h handle) => tizen.rpc_port_proxy_destroy(handle));

/// The server application ID.
final String appid;
Expand Down
7 changes: 3 additions & 4 deletions packages/tizen_rpc_port/lib/src/stub_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ abstract class StubBase {
return pStub.value;
});

_finalizer.attach(this, this);
_finalizer.attach(this, _handle);
}

late final rpc_port_stub_h _handle;

final Finalizer<StubBase> _finalizer = Finalizer<StubBase>((StubBase stub) {
stub.close();
});
final Finalizer<rpc_port_stub_h> _finalizer = Finalizer<rpc_port_stub_h>(
(rpc_port_stub_h handle) => tizen.rpc_port_stub_destroy(handle));

/// A port name to use when listening for connections.
final String portName;
Expand Down