Mercurial > pidgin
comparison finch/gntsound.c @ 19143:3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 07 Jul 2007 01:30:42 +0000 |
parents | 5f2bcb110f00 |
children | 5ff1231993af |
comparison
equal
deleted
inserted
replaced
19142:5f2bcb110f00 | 19143:3bec25803a00 |
---|---|
68 GntWidget *conv_focus; | 68 GntWidget *conv_focus; |
69 GntWidget *while_status; | 69 GntWidget *while_status; |
70 GntWidget *volume; | 70 GntWidget *volume; |
71 GntWidget *events; | 71 GntWidget *events; |
72 GntWidget *window; | 72 GntWidget *window; |
73 GntWidget *selector; | |
73 } SoundPrefDialog; | 74 } SoundPrefDialog; |
74 | 75 |
75 SoundPrefDialog *pref_dialog; | 76 SoundPrefDialog *pref_dialog; |
76 | 77 |
77 #define PLAY_SOUND_TIMEOUT 15000 | 78 #define PLAY_SOUND_TIMEOUT 15000 |
648 { | 649 { |
649 GntWidget *w = gnt_file_sel_new(); | 650 GntWidget *w = gnt_file_sel_new(); |
650 GntFileSel *sel = GNT_FILE_SEL(w); | 651 GntFileSel *sel = GNT_FILE_SEL(w); |
651 PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events))); | 652 PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events))); |
652 FinchSoundEvent * event = &sounds[id]; | 653 FinchSoundEvent * event = &sounds[id]; |
654 char *path = NULL; | |
653 | 655 |
654 gnt_file_sel_set_current_location(sel, | 656 gnt_file_sel_set_current_location(sel, |
655 (event && event->file) ? g_path_get_dirname(event->file) : purple_home_dir()); | 657 (event && event->file) ? (path = g_path_get_dirname(event->file)) |
658 : purple_home_dir()); | |
656 | 659 |
657 g_signal_connect_swapped(G_OBJECT(sel->cancel),"activate",G_CALLBACK(gnt_widget_destroy),sel); | 660 g_signal_connect_swapped(G_OBJECT(sel->cancel),"activate",G_CALLBACK(gnt_widget_destroy),sel); |
658 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_cb), event); | 661 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_cb), event); |
662 g_signal_connect_swapped(G_OBJECT(sel), "destroy", G_CALLBACK(g_nullify_pointer), &pref_dialog->selector); | |
663 | |
664 /* If there's an already open file-selector, close that one. */ | |
665 if (pref_dialog->selector) | |
666 gnt_widget_destroy(pref_dialog->selector); | |
667 | |
668 pref_dialog->selector = w; | |
659 | 669 |
660 gnt_widget_show(w); | 670 gnt_widget_show(w); |
671 g_free(path); | |
661 } | 672 } |
662 | 673 |
663 static void | 674 static void |
664 release_pref_dialog(GntBindable *data, gpointer null) | 675 release_pref_dialog(GntBindable *data, gpointer null) |
665 { | 676 { |
667 for(itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events));itr;itr = itr->next){ | 678 for(itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events));itr;itr = itr->next){ |
668 PurpleSoundEventID id = GPOINTER_TO_INT(itr->data); | 679 PurpleSoundEventID id = GPOINTER_TO_INT(itr->data); |
669 FinchSoundEvent * e = &sounds[id]; | 680 FinchSoundEvent * e = &sounds[id]; |
670 g_free(e->file); | 681 g_free(e->file); |
671 } | 682 } |
683 if (pref_dialog->selector) | |
684 gnt_widget_destroy(pref_dialog->selector); | |
672 g_free(pref_dialog); | 685 g_free(pref_dialog); |
673 pref_dialog = NULL; | 686 pref_dialog = NULL; |
674 } | 687 } |
675 | 688 |
676 void | 689 void |
816 button = gnt_button_new(_("Cancel")); | 829 button = gnt_button_new(_("Cancel")); |
817 g_signal_connect_swapped(G_OBJECT(button),"activate",G_CALLBACK(gnt_widget_destroy),win); | 830 g_signal_connect_swapped(G_OBJECT(button),"activate",G_CALLBACK(gnt_widget_destroy),win); |
818 gnt_box_add_widget(GNT_BOX(box),button); | 831 gnt_box_add_widget(GNT_BOX(box),button); |
819 gnt_box_add_widget(GNT_BOX(win),box); | 832 gnt_box_add_widget(GNT_BOX(win),box); |
820 | 833 |
821 | |
822 g_signal_connect(G_OBJECT(win),"destroy",G_CALLBACK(release_pref_dialog),NULL); | 834 g_signal_connect(G_OBJECT(win),"destroy",G_CALLBACK(release_pref_dialog),NULL); |
823 | 835 |
824 gnt_widget_show(win); | 836 gnt_widget_show(win); |
825 | 837 |
826 } | 838 } |