@@ -1658,6 +1658,7 @@ pub unsafe extern "C" fn dc_get_chat(context: *mut dc_context_t, chat_id: u32) -
1658
1658
return ptr:: null_mut ( ) ;
1659
1659
}
1660
1660
let ctx = & * context;
1661
+ let context: Context = ctx. clone ( ) ;
1661
1662
1662
1663
block_on ( async move {
1663
1664
match chat:: Chat :: load_from_db ( ctx, ChatId :: new ( chat_id) ) . await {
@@ -2982,7 +2983,7 @@ pub unsafe extern "C" fn dc_chatlist_get_context(
2982
2983
/// context, but the Rust API does not, so the FFI layer needs to glue
2983
2984
/// these together.
2984
2985
pub struct ChatWrapper {
2985
- context : * const dc_context_t ,
2986
+ context : Context ,
2986
2987
chat : chat:: Chat ,
2987
2988
}
2988
2989
@@ -3049,14 +3050,13 @@ pub unsafe extern "C" fn dc_chat_get_profile_image(chat: *mut dc_chat_t) -> *mut
3049
3050
return ptr:: null_mut ( ) ; // NULL explicitly defined as "no image"
3050
3051
}
3051
3052
let ffi_chat = & * chat;
3052
- let ctx = & * ffi_chat. context ;
3053
3053
3054
3054
block_on ( async move {
3055
- match ffi_chat. chat . get_profile_image ( ctx ) . await {
3055
+ match ffi_chat. chat . get_profile_image ( & ffi_chat . context ) . await {
3056
3056
Ok ( Some ( p) ) => p. to_string_lossy ( ) . strdup ( ) ,
3057
3057
Ok ( None ) => ptr:: null_mut ( ) ,
3058
3058
Err ( err) => {
3059
- error ! ( ctx , "failed to get profile image: {err:#}" ) ;
3059
+ error ! ( ffi_chat . context , "failed to get profile image: {err:#}" ) ;
3060
3060
ptr:: null_mut ( )
3061
3061
}
3062
3062
}
@@ -3070,9 +3070,9 @@ pub unsafe extern "C" fn dc_chat_get_color(chat: *mut dc_chat_t) -> u32 {
3070
3070
return 0 ;
3071
3071
}
3072
3072
let ffi_chat = & * chat;
3073
- let ctx = & * ffi_chat. context ;
3074
3073
3075
- block_on ( ffi_chat. chat . get_color ( ctx) ) . unwrap_or_log_default ( ctx, "Failed get_color" )
3074
+ block_on ( ffi_chat. chat . get_color ( & ffi_chat. context ) )
3075
+ . unwrap_or_log_default ( & ffi_chat. context , "Failed get_color" )
3076
3076
}
3077
3077
3078
3078
#[ no_mangle]
@@ -3136,10 +3136,9 @@ pub unsafe extern "C" fn dc_chat_can_send(chat: *mut dc_chat_t) -> libc::c_int {
3136
3136
return 0 ;
3137
3137
}
3138
3138
let ffi_chat = & * chat;
3139
- let ctx = & * ffi_chat. context ;
3140
- block_on ( ffi_chat. chat . can_send ( ctx) )
3139
+ block_on ( ffi_chat. chat . can_send ( & ffi_chat. context ) )
3141
3140
. context ( "can_send failed" )
3142
- . log_err ( ctx )
3141
+ . log_err ( & ffi_chat . context )
3143
3142
. unwrap_or_default ( ) as libc:: c_int
3144
3143
}
3145
3144
0 commit comments