Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: free chewing objects with chewing_free #241

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/IBusChewingLookupTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
guint size = 10;
gboolean cursorShow = TRUE;
gboolean wrapAround = TRUE;
IBusLookupTable *iTable =
ibus_lookup_table_new(size, 0, cursorShow, wrapAround);
IBusLookupTable *iTable = ibus_lookup_table_new(size, 0, cursorShow, wrapAround);

ibus_chewing_lookup_table_resize(iTable, context);

return iTable;
}

void ibus_chewing_lookup_table_resize(IBusLookupTable *iTable,
ChewingContext *context) {
void ibus_chewing_lookup_table_resize(IBusLookupTable *iTable, ChewingContext *context) {
gint selKSym[MAX_SELKEY];
g_autoptr(GSettings) settings = g_settings_new(QUOTE_ME(PROJECT_SCHEMA_ID));
g_autofree char *selKeyStr = g_settings_get_string(settings, "sel-keys");
Expand All @@ -34,23 +32,20 @@
for (i = 0; i < len; i++) {
selKSym[i] = (gint)selKeyStr[i];

iText = g_object_ref_sink(
ibus_text_new_from_printf("%c.", toupper(selKeyStr[i])));
iText = g_object_ref_sink(ibus_text_new_from_printf("%c.", toupper(selKeyStr[i])));
ibus_lookup_table_set_label(iTable, i, iText);
g_object_unref(iText);
}
}
chewing_set_candPerPage(context, len);
chewing_set_selKey(context, selKSym, len);

gboolean verticalLookupTable =
g_settings_get_boolean(settings, "vertical-lookup-table");
gboolean verticalLookupTable = g_settings_get_boolean(settings, "vertical-lookup-table");

ibus_lookup_table_set_orientation(iTable, verticalLookupTable);
}

guint ibus_chewing_lookup_table_update(IBusLookupTable *iTable,
ChewingContext *context) {
guint ibus_chewing_lookup_table_update(IBusLookupTable *iTable, ChewingContext *context) {
IBusText *iText = NULL;
gint i;
gint choicePerPage = chewing_cand_ChoicePerPage(context);
Expand All @@ -70,7 +65,7 @@

iText = g_object_ref_sink(ibus_text_new_from_string(candidate));
ibus_lookup_table_append_candidate(iTable, iText);
g_free(candidate);
chewing_free(candidate);

Check warning on line 68 in src/IBusChewingLookupTable.c

View check run for this annotation

Codecov / codecov/patch

src/IBusChewingLookupTable.c#L68

Added line #L68 was not covered by tests
g_object_unref(iText);
} else {
break;
Expand Down
3 changes: 2 additions & 1 deletion src/IBusChewingPreEdit.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void ibus_chewing_pre_edit_free(IBusChewingPreEdit *self) {
}

gchar *ibus_chewing_pre_edit_get_bopomofo_string(IBusChewingPreEdit *self) {
// FIXME: libchewing should provide chewing_bopomofo_String(ctx)
const gchar *buf = chewing_bopomofo_String_static(self->context);

return g_strdup(buf);
Expand Down Expand Up @@ -94,7 +95,7 @@ void ibus_chewing_pre_edit_update(IBusChewingPreEdit *self) {

self->wordLen = i + self->bpmfLen;

g_free(bufferStr);
chewing_free(bufferStr);
g_free(bpmfStr);

ibus_chewing_pre_edit_update_outgoing(self);
Expand Down
4 changes: 2 additions & 2 deletions src/ibus-chewing-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@

IBUS_CHEWING_LOG(INFO, "update_aux_text() auxStr=%s", auxStr);
self->auxText = g_object_ref_sink(ibus_text_new_from_string(auxStr));
g_free(auxStr);
chewing_free(auxStr);
} else if (self->prop_notify_mode_change && self->pending_notify_chinese_english_mode) {
self->pending_notify_chinese_english_mode = FALSE;
char *auxStr = is_chinese_mode(self) ? _("Chinese Mode") : _("English Mode");
Expand Down Expand Up @@ -1073,7 +1073,7 @@
KSym k = (KSym)selKeys[index];

ibus_chewing_pre_edit_process_key(self->icPreEdit, k, 0);
g_free(selKeys);
chewing_free(selKeys);

Check warning on line 1076 in src/ibus-chewing-engine.c

View check run for this annotation

Codecov / codecov/patch

src/ibus-chewing-engine.c#L1076

Added line #L1076 was not covered by tests
ibus_chewing_engine_update(self);
} else {
IBUS_CHEWING_LOG(DEBUG, "candidate_clicked() ... candidates are not showing");
Expand Down
Loading