Commit 6eda32d7 authored by François Grisez's avatar François Grisez
Browse files

Fix some memory leaks about pixbufs

parent 7c8abd50
......@@ -343,7 +343,7 @@ static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name)
linphone_gtk_visibility_set(shown,window_name,w,TRUE);
if (icon_path) {
GdkPixbuf *pbuf=create_pixbuf(icon_path);
if(pbuf != NULL) {
if(pbuf) {
GList *pbuf_list = NULL;
GdkPixbuf *pbuf_16=gdk_pixbuf_scale_simple(pbuf, 16, 16, GDK_INTERP_BILINEAR);
GdkPixbuf *pbuf_32=gdk_pixbuf_scale_simple(pbuf, 32, 32, GDK_INTERP_BILINEAR);
......@@ -352,10 +352,7 @@ static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name)
pbuf_list = g_list_append(pbuf_list, pbuf_32);
gtk_window_set_icon_list(GTK_WINDOW(w), pbuf_list);
gtk_window_set_default_icon_list(pbuf_list);
g_object_unref(G_OBJECT(pbuf_16));
g_object_unref(G_OBJECT(pbuf_32));
g_object_unref(G_OBJECT(pbuf));
g_list_free(pbuf_list);
g_list_free_full(pbuf_list, g_object_unref);
}
}
}
......@@ -546,7 +543,10 @@ void linphone_gtk_show_about(void){
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),LIBLINPHONE_GIT_VERSION);
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about),linphone_gtk_get_ui_config("title","Linphone"));
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about),linphone_gtk_get_ui_config("home","http://www.linphone.org"));
if (logo) gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about),logo);
if (logo) {
gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), logo);
g_object_unref(logo);
}
tmp=linphone_gtk_get_ui_config("artists",defcfg);
if (tmp!=defcfg){
const char *tmp2[2];
......@@ -1735,7 +1735,7 @@ static void linphone_gtk_configure_main_window(){
}
if (search_icon){
GdkPixbuf *pbuf=create_pixbuf(search_icon);
if(pbuf != NULL) {
if(pbuf) {
gtk_image_set_from_pixbuf(GTK_IMAGE(linphone_gtk_get_widget(w,"directory_search_button_icon")),pbuf);
g_object_unref(G_OBJECT(pbuf));
}
......@@ -1760,6 +1760,7 @@ static void linphone_gtk_configure_main_window(){
if (pbuf) {
GtkButton *button=GTK_BUTTON(linphone_gtk_get_widget(w,"keypad"));
gtk_button_set_image(button,gtk_image_new_from_pixbuf (pbuf));
g_object_unref(pbuf);
}
}
if (linphone_gtk_can_manage_accounts()) {
......@@ -2169,7 +2170,10 @@ int main(int argc, char *argv[]){
}
g_set_application_name(app_name);
pbuf=create_pixbuf(icon_path);
if (pbuf!=NULL) gtk_window_set_default_icon(pbuf);
if (pbuf) {
gtk_window_set_default_icon(pbuf);
g_object_unref(pbuf);
}
#ifdef HAVE_GTK_OSX
GtkosxApplication *theMacApp = gtkosx_application_get();
......
......@@ -26,8 +26,6 @@ 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;
static GtkWidget *create_intro(){
GtkWidget *vbox=gtk_vbox_new(FALSE,2);
......@@ -205,10 +203,12 @@ static void account_email_changed(GtkEntry *entry, GtkWidget *w) {
GtkWidget *assistant=gtk_widget_get_toplevel(w);
if (g_regex_match_simple("^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$", gtk_entry_get_text(email), 0, 0)) {
GdkPixbuf *ok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "ok"));
g_object_set_data(G_OBJECT(w),"is_email_correct",GINT_TO_POINTER(1));
gtk_image_set_from_pixbuf(isEmailOk, ok);
}
else {
GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok"));
g_object_set_data(G_OBJECT(w),"is_email_correct",GINT_TO_POINTER(0));
gtk_image_set_from_pixbuf(isEmailOk, notok);
}
......@@ -227,11 +227,13 @@ static void account_password_changed(GtkEntry *entry, GtkWidget *w) {
if (gtk_entry_get_text_length(password) >= PASSWORD_MIN_SIZE &&
g_ascii_strcasecmp(gtk_entry_get_text(password), gtk_entry_get_text(password_confirm)) == 0) {
GdkPixbuf *ok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "ok"));
g_object_set_data(G_OBJECT(w),"is_password_correct",GINT_TO_POINTER(1));
gtk_image_set_from_pixbuf(isPasswordOk, ok);
gtk_label_set_text(passwordError, "");
}
else {
GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok"));
if (gtk_entry_get_text_length(password) < PASSWORD_MIN_SIZE) {
gtk_label_set_text(passwordError, "Password is too short !");
}
......@@ -252,11 +254,13 @@ gboolean update_interface_with_username_availability(gpointer *w) {
int account_existing = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"is_username_used"));
if (account_existing == 0) {
GdkPixbuf *ok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "ok"));
g_object_set_data(G_OBJECT(w),"is_username_available",GINT_TO_POINTER(1));
gtk_image_set_from_pixbuf(isUsernameOk, ok);
gtk_label_set_text(usernameError, "");
}
else {
GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok"));
gtk_label_set_text(usernameError, "Username is already in use !");
g_object_set_data(G_OBJECT(w),"is_username_available",GINT_TO_POINTER(0));
gtk_image_set_from_pixbuf(isUsernameOk, notok);
......@@ -297,6 +301,7 @@ static void account_username_changed(GtkEntry *entry, GtkWidget *w) {
#endif
}
else {
GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok"));
if (gtk_entry_get_text_length(username) < LOGIN_MIN_SIZE) {
gtk_label_set_text(usernameError, "Username is too short");
}
......@@ -313,7 +318,7 @@ static void account_username_changed(GtkEntry *entry, GtkWidget *w) {
static GtkWidget *create_account_information_page() {
GtkWidget *vbox=gtk_table_new(7, 3, FALSE);
GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok"));
GtkWidget *label=gtk_label_new(_("(*) Required fields"));
GtkWidget *labelUsername=gtk_label_new(_("Username: (*)"));
GtkWidget *isUsernameOk=gtk_image_new_from_pixbuf(notok);
......@@ -595,6 +600,8 @@ void linphone_gtk_show_assistant(void){
GtkWidget *validate;
GtkWidget *error;
GtkWidget *end;
GdkPixbuf *ok;
GdkPixbuf *notok;
if(the_assistant!=NULL)
return;
w=the_assistant=gtk_assistant_new();
......@@ -602,7 +609,9 @@ void linphone_gtk_show_assistant(void){
gtk_window_set_title(GTK_WINDOW(w),_("SIP account configuration assistant"));
ok = create_pixbuf(linphone_gtk_get_ui_config("ok","ok.png"));
g_object_set_data_full(G_OBJECT(the_assistant), "ok", ok, g_object_unref);
notok = create_pixbuf(linphone_gtk_get_ui_config("notok","notok.png"));
g_object_set_data_full(G_OBJECT(the_assistant), "notok", notok, g_object_unref);
p1=create_intro();
p2=create_setup_signin_choice();
......
......@@ -293,10 +293,10 @@ static void _linphone_status_icon_impl_gtk_init(LinphoneStatusIcon *si) {
GtkStatusIcon *icon=gtk_status_icon_new_from_pixbuf(pbuf);
g_signal_connect_swapped(G_OBJECT(icon),"activate", G_CALLBACK(_linphone_status_icon_impl_gtk_on_click_cb), si);
g_signal_connect(G_OBJECT(icon), "popup-menu", G_CALLBACK(_linphone_status_icon_impl_gtk_popup_menu), si);
g_object_set_data(G_OBJECT(icon),"icon",pbuf);
g_object_set_data_full(G_OBJECT(icon),"icon",pbuf, g_object_unref);
g_object_unref(pbuf);
pbuf=create_pixbuf(call_icon_path);
g_object_set_data(G_OBJECT(icon),"call_icon",pbuf);
g_object_set_data_full(G_OBJECT(icon),"call_icon",pbuf, g_object_unref);
g_object_unref(pbuf);
si->data = icon;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment