let get_selection_account return an Option<>

This commit is contained in:
B. Petersen
2021-06-17 22:23:43 +02:00
committed by link2xt
parent 4c4f24fb35
commit b53613d1e0
3 changed files with 8 additions and 11 deletions

View File

@@ -2486,6 +2486,7 @@ dc_context_t* dc_accounts_get_account (dc_accounts_t* accounts, uint32
* unmanaged account-context as created by dc_context_new().
* Once you do no longer need the context-object, you have to call dc_context_unref() on it,
* which, however, will not close the account but only decrease a reference counter.
* If there is no selected account, NULL is returned.
*/
dc_context_t* dc_accounts_get_selected_account (dc_accounts_t* accounts);

View File

@@ -3695,8 +3695,9 @@ pub unsafe extern "C" fn dc_accounts_get_selected_account(
}
let accounts = &*accounts;
let ctx = block_on(accounts.get_selected_account());
Box::into_raw(Box::new(ctx))
block_on(accounts.get_selected_account())
.map(|ctx| Box::into_raw(Box::new(ctx)))
.unwrap_or_else(std::ptr::null_mut)
}
#[no_mangle]