mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
Fix issue with assistant and memory leak
This commit is contained in:
parent
2c0a6e9920
commit
ace4380e5c
5 changed files with 36 additions and 20 deletions
|
|
@ -53,10 +53,13 @@ GtkWidget*create_pixmap(const gchar *filename);
|
|||
GtkWidget *_gtk_image_new_from_memory_at_scale(const void *data, gint len, gint w, gint h, gboolean preserve_ratio);
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_memory_at_scale(const void *data, gint len, gint w, gint h, gboolean preserve_ratio);
|
||||
|
||||
void linphone_gtk_destroy_window(GtkWidget *window);
|
||||
GtkWidget *linphone_gtk_create_window(const char *window_name);
|
||||
GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name);
|
||||
GtkWidget *linphone_gtk_create_widget(const char *filename, const char *widget_name);
|
||||
GtkWidget * linphone_gtk_create_assistant(void);
|
||||
|
||||
void linphone_gtk_show_assistant(void);
|
||||
void linphone_gtk_close_assistant(void);
|
||||
|
||||
LinphoneCore *linphone_gtk_get_core(void);
|
||||
GtkWidget *linphone_gtk_get_main_window();
|
||||
|
|
|
|||
29
gtk/main.c
29
gtk/main.c
|
|
@ -50,7 +50,6 @@ const char *this_program_ident_string="linphone_ident_string=" LINPHONE_VERSION;
|
|||
|
||||
static LinphoneCore *the_core=NULL;
|
||||
static GtkWidget *the_ui=NULL;
|
||||
GtkWidget *the_wizard=NULL;
|
||||
|
||||
static void linphone_gtk_registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState rs, const char *msg);
|
||||
static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid);
|
||||
|
|
@ -257,6 +256,11 @@ GtkWidget *linphone_gtk_get_main_window(){
|
|||
return the_ui;
|
||||
}
|
||||
|
||||
void linphone_gtk_destroy_main_window() {
|
||||
linphone_gtk_destroy_window(the_ui);
|
||||
the_ui = NULL;
|
||||
}
|
||||
|
||||
static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name){
|
||||
static const char *icon_path=NULL;
|
||||
static const char *hiddens=NULL;
|
||||
|
|
@ -295,6 +299,12 @@ static int get_ui_file(const char *name, char *path, int pathsize){
|
|||
return 0;
|
||||
}
|
||||
|
||||
void linphone_gtk_destroy_window(GtkWidget *widget) {
|
||||
GtkBuilder* builder = g_object_get_data(G_OBJECT(widget), "builder");
|
||||
gtk_widget_destroy(widget);
|
||||
g_object_unref (G_OBJECT (builder));
|
||||
}
|
||||
|
||||
GtkWidget *linphone_gtk_create_window(const char *window_name){
|
||||
GError* error = NULL;
|
||||
GtkBuilder* builder = gtk_builder_new ();
|
||||
|
|
@ -313,7 +323,7 @@ GtkWidget *linphone_gtk_create_window(const char *window_name){
|
|||
g_error("Could not retrieve '%s' window from xml file",window_name);
|
||||
return NULL;
|
||||
}
|
||||
g_object_set_data(G_OBJECT(w),"builder",builder);
|
||||
g_object_set_data(G_OBJECT(w), "builder",builder);
|
||||
gtk_builder_connect_signals(builder,w);
|
||||
linphone_gtk_configure_window(w,window_name);
|
||||
return w;
|
||||
|
|
@ -1731,21 +1741,16 @@ static void linphone_gtk_check_soundcards(){
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef BUILD_WIZARD
|
||||
// Display the account wizard
|
||||
void linphone_gtk_display_wizard() {
|
||||
if (the_wizard == NULL || !gtk_widget_get_visible(the_wizard)) { // Only one instance of the wizard at the same time
|
||||
the_wizard = linphone_gtk_create_assistant();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void linphone_gtk_quit(void){
|
||||
static gboolean quit_done=FALSE;
|
||||
if (!quit_done){
|
||||
quit_done=TRUE;
|
||||
linphone_gtk_unmonitor_usb();
|
||||
g_source_remove_by_user_data(linphone_gtk_get_core());
|
||||
#ifdef BUILD_WIZARD
|
||||
linphone_gtk_close_assistant();
|
||||
#endif
|
||||
linphone_gtk_destroy_main_window();
|
||||
linphone_gtk_uninit_instance();
|
||||
linphone_gtk_destroy_log_window();
|
||||
linphone_core_destroy(the_core);
|
||||
|
|
@ -1897,7 +1902,7 @@ int main(int argc, char *argv[]){
|
|||
#ifdef BUILD_WIZARD
|
||||
// Veryfing if at least one sip account is configured. If not, show wizard
|
||||
if (linphone_core_get_proxy_config_list(linphone_gtk_get_core()) == NULL) {
|
||||
linphone_gtk_display_wizard();
|
||||
linphone_gtk_show_assistant();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -834,7 +834,7 @@
|
|||
<property name="use_action_appearance">False</property>
|
||||
<property name="image">image12</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="linphone_gtk_display_wizard" swapped="no"/>
|
||||
<signal name="activate" handler="linphone_gtk_show_assistant" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
|||
|
|
@ -1429,7 +1429,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="linphone_gtk_display_wizard" swapped="no"/>
|
||||
<signal name="clicked" handler="linphone_gtk_show_assistant" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox5">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ static LinphoneAccountCreator *linphone_gtk_assistant_get_creator(GtkWidget*w);
|
|||
static const int PASSWORD_MIN_SIZE = 6;
|
||||
static const int LOGIN_MIN_SIZE = 4;
|
||||
|
||||
static GtkWidget *the_assistant=NULL;
|
||||
static GdkPixbuf *ok;
|
||||
static GdkPixbuf *notok;
|
||||
|
||||
|
|
@ -400,7 +401,7 @@ static int is_account_validated(GtkWidget *page) {
|
|||
}
|
||||
|
||||
static void linphone_gtk_assistant_closed(GtkWidget *w){
|
||||
gtk_widget_destroy(w);
|
||||
linphone_gtk_close_assistant();
|
||||
}
|
||||
|
||||
static void linphone_gtk_assistant_prepare(GtkWidget *assistant, GtkWidget *page){
|
||||
|
|
@ -531,8 +532,17 @@ static LinphoneAccountCreator *linphone_gtk_assistant_get_creator(GtkWidget*w){
|
|||
return (LinphoneAccountCreator*)g_object_get_data(G_OBJECT(w),"creator");
|
||||
}
|
||||
|
||||
GtkWidget * linphone_gtk_create_assistant(void){
|
||||
GtkWidget *w=gtk_assistant_new();
|
||||
void linphone_gtk_close_assistant(void){
|
||||
if(the_assistant==NULL)
|
||||
return;
|
||||
gtk_widget_destroy(the_assistant);
|
||||
the_assistant = NULL;
|
||||
}
|
||||
|
||||
void linphone_gtk_show_assistant(void){
|
||||
if(the_assistant!=NULL)
|
||||
return;
|
||||
GtkWidget *w=the_assistant=gtk_assistant_new();
|
||||
gtk_window_set_resizable (GTK_WINDOW(w), FALSE);
|
||||
|
||||
ok = create_pixbuf(linphone_gtk_get_ui_config("ok","ok.png"));
|
||||
|
|
@ -597,7 +607,5 @@ GtkWidget * linphone_gtk_create_assistant(void){
|
|||
g_signal_connect(G_OBJECT(w),"prepare",(GCallback)linphone_gtk_assistant_prepare,NULL);
|
||||
|
||||
gtk_widget_show(w);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue