Skip to content

Commit f9b3b42

Browse files
authored
Merge pull request #37 from ray2501/master
Add code to check OpenCC handle
2 parents 7b720ac + 5894ad2 commit f9b3b42

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/engine.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static gboolean is_output_simplified;
108108
static gboolean is_aux_shown = FALSE;
109109
static ArrayContext *array_context = NULL;
110110
#ifdef HAVE_OPENCC
111-
static opencc_t cc_handle;
111+
static opencc_t cc_handle = NULL;;
112112
#endif
113113

114114
GType ibus_array_engine_get_type (void) {
@@ -173,7 +173,8 @@ void ibus_array_init (IBusBus *bus) {
173173
void ibus_array_exit (void)
174174
{
175175
#ifdef HAVE_OPENCC
176-
opencc_close(cc_handle);
176+
if (cc_handle)
177+
opencc_close(cc_handle);
177178
#endif
178179

179180
array_release_context(array_context);
@@ -442,7 +443,7 @@ static gboolean ibus_array_engine_commit_current_candidate (IBusArrayEngine *arr
442443
}
443444

444445
#ifdef HAVE_OPENCC
445-
if (is_output_simplified) {
446+
if (is_output_simplified && cc_handle != NULL) {
446447
char *converted = opencc_convert_utf8(cc_handle,
447448
text->text,
448449
strlen(text->text));

0 commit comments

Comments
 (0)