Permalink
Browse files

Fix SEGV by clicking a candidate shown by uim-bushuconv.

Change to emit index-changed signal after selection changed,
instead of emitting before selection change.

* gtk2/immodule/uim-cand-win-vertical-gtk.c
  - (tree_selection_change): Change not to emit signal here.
  - (tree_selection_changed): Emit signal if index_changed flag is set.
* gtk2/immodule/uim-cand-win-gtk.h
  - (_UIMCandWinGtk): Add member variable index_changed.
* gtk2/immodule/uim-cand-win-gtk.c
  - (uim_cand_win_gtk_init): Add initialization of index_changed variable.
  • Loading branch information...
KIHARA Hideto
KIHARA Hideto committed Aug 31, 2012
1 parent 13cfdfe commit bc40465eef8b5674a79a12ab942422be6e70a0ef
@@ -169,6 +169,7 @@ uim_cand_win_gtk_init (UIMCandWinGtk *cwin)
uim_cand_win_gtk_get_window_pos_type(cwin);
cwin->block_index_selection = FALSE;
cwin->index_changed = FALSE;
cwin->cursor.x = cwin->cursor.y = 0;
cwin->cursor.width = cwin->cursor.height = 0;
@@ -74,6 +74,7 @@ struct _UIMCandWinGtk {
GdkRectangle cursor;
gboolean block_index_selection;
gboolean index_changed;
/* sub window */
struct sub_window {
@@ -209,7 +209,13 @@ tree_selection_change(GtkTreeSelection *selection,
if (!path_currently_selected && cwin->candidate_index != idx) {
if (cwin->candidate_index >= 0) {
cwin->candidate_index = idx;
g_signal_emit_by_name(G_OBJECT(cwin), "index-changed");
/* if emit "index-changed" here and IM deactivates this candwin,
* activates new candwin and selects a candidate on new candwin
* from index-changed callback, SEGV occurs in gtk because gtk tries to
* select on old candwin after return of this tree_selection_change().
* To avoid SEGV, instead of emitting before selection change by gtk,
* emit after selection changed by gtk. */
cwin->index_changed = TRUE;
}
uim_cand_win_gtk_update_label(cwin);
@@ -264,6 +270,11 @@ tree_selection_changed(GtkTreeSelection *selection,
}
}
if (cwin->index_changed) {
cwin->index_changed = FALSE;
g_signal_emit_by_name(G_OBJECT(cwin), "index-changed");
}
return TRUE;
}

0 comments on commit bc40465

Please sign in to comment.