diff --git a/src/ai/ai_client.c b/src/ai/ai_client.c index f49f1ef2..da891e8d 100644 --- a/src/ai/ai_client.c +++ b/src/ai/ai_client.c @@ -205,7 +205,7 @@ ai_provider_new(const gchar* name, const gchar* api_url, const gchar* org_id) return provider; } -static AIProvider* +AIProvider* ai_provider_ref(AIProvider* provider) { if (provider) { diff --git a/src/ai/ai_client.h b/src/ai/ai_client.h index 385b8510..eb41bcce 100644 --- a/src/ai/ai_client.h +++ b/src/ai/ai_client.h @@ -78,6 +78,13 @@ AIProvider* ai_add_provider(const gchar* name, const gchar* api_url, const gchar */ gboolean ai_remove_provider(const gchar* name); +/** + * Increment the reference count of a provider. + * @param provider The provider to reference + * @return The same provider pointer + */ +AIProvider* ai_provider_ref(AIProvider* provider); + /** * Decrement the reference count of a provider. * @param provider The provider to unreference diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index f2de429c..79ffc094 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -11115,7 +11115,7 @@ cmd_ai_switch(ProfWin* window, const char* const command, gchar** args) aiwin->session->provider_name = g_strdup(provider_name); ai_provider_unref(aiwin->session->provider); aiwin->session->provider = new_provider; - aiwin->session->provider->ref_count++; + ai_provider_ref(aiwin->session->provider); } g_free(aiwin->session->model); aiwin->session->model = g_strdup(model);