File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
twackup-gui/Twackup/Sources/FFI Models Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ final class DpkgProgressNotifier: @unchecked Sendable {
41
41
// MARK: - Private methods
42
42
43
43
private func initFuncs( ) {
44
- ffiFunctions. context = Unmanaged . passUnretained ( self ) . toOpaque ( )
44
+ // Temporarily make a leak and consume it in finished_all func
45
+ ffiFunctions. context = Unmanaged . passRetained ( self ) . toOpaque ( )
45
46
ffiFunctions. started_processing = { context, package in
46
47
guard let context, let ffiPackage = FFIPackage ( package ) else {
47
48
tw_package_release ( package . inner)
@@ -66,7 +67,7 @@ final class DpkgProgressNotifier: @unchecked Sendable {
66
67
ffiFunctions. finished_all = { context in
67
68
guard let context else { return }
68
69
69
- let dpkg = Unmanaged < DpkgProgressNotifier > . fromOpaque ( context) . takeUnretainedValue ( )
70
+ let dpkg = Unmanaged < DpkgProgressNotifier > . fromOpaque ( context) . takeRetainedValue ( )
70
71
dpkg. finishedAll ( )
71
72
}
72
73
}
Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ actor FFILogger {
56
56
}
57
57
58
58
var funcs = TwLogFunctions ( )
59
+ // Intented leak since logger can be deinited in Swift but pointer will be saved by Rust struct
60
+ // and it will crash in some of this C-style handlers
61
+ //
62
+ // Maybe there should be some kind of `deinit` func which will balance RC
63
+ // but Rust log crate doesn't support deiniting yet
59
64
funcs. context = Unmanaged < FFILogger > . passRetained ( self ) . toOpaque ( )
60
65
funcs. log = { context, ffiMsg, level in
61
66
guard let context,
You can’t perform that action at this time.
0 commit comments