[uim-commit] r228 - trunk/uim

tkng@freedesktop.org tkng@freedesktop.org
Mon Jan 10 13:44:09 PST 2005


Author: tkng
Date: 2005-01-10 13:44:06 -0800 (Mon, 10 Jan 2005)
New Revision: 228

Modified:
   trunk/uim/uim.c
Log:
* uim/uim.c:
 -(get_context_id): Substitute -1 if there's no free context slot.
 -(uim_create_context): Fail if id == -1
 -(uim_switch_im): Call release-context before calling create-context.
 -(uim_release_context):substitute NULL to uc->modes[i] after freed.


Modified: trunk/uim/uim.c
===================================================================
--- trunk/uim/uim.c	2005-01-10 21:33:07 UTC (rev 227)
+++ trunk/uim/uim.c	2005-01-10 21:44:06 UTC (rev 228)
@@ -55,7 +55,7 @@
 
 char *uim_last_client_encoding;
 
-#define CONTEXT_ARRAY_SIZE 512
+#define CONTEXT_ARRAY_SIZE 5
 static uim_context context_array[CONTEXT_ARRAY_SIZE];
 struct uim_im *uim_im_array;
 int uim_nr_im;
@@ -85,6 +85,7 @@
       return;
     }
   }
+  uc->id = -1;
 }
 
 static void
@@ -116,6 +117,9 @@
     return NULL;
   }
   get_context_id(uc);
+  if(uc->id == -1)
+    return NULL;
+
   uc->ptr = ptr;
   uc->is_enable = 1;
   uc->commit_cb = commit_cb;
@@ -214,8 +218,13 @@
      immodule API. We should follow its design to make our API simple.
      -- 2004-10-05 YamaKen
   */
-  uim_reset_context(uc);
-  UIM_EVAL_FSTRING2(uc, "(create-context %d #f '%s)", uc->id, engine);
+  int id = uc->id;
+  uim_reset_context(uc); /* FIXME: reset should be called here? */
+
+  UIM_EVAL_FSTRING1(uc, "(release-context %d)", uc->id);
+  uim_release_preedit_segments(uc);
+
+  UIM_EVAL_FSTRING2(uc, "(create-context %d #f '%s)", id, engine);
   if (uc->current_im_name)
     free(uc->current_im_name);
   uc->current_im_name = strdup(engine);



More information about the Uim-commit mailing list