[LDTP-Dev] [PATCH] fix for bug #318189

jpremkumar jpremkumar at novell.com
Fri Oct 7 04:41:46 PDT 2005


Hi

I have attached patch for bug #318189. This bug is about remap not
working when used after the dialog's title changes at run time. This bug
resolves the problem by retaining the entry corresponding to the main
dialog from old hashtable itself, instead of generating it at runtime.

Please review them.

Thanks
Premkumar J

Index: ldtp.c
===================================================================
RCS file: /cvs/pyldtp/ldtp.c,v
retrieving revision 1.134
diff -u -p -r1.134 ldtp.c
--- ldtp.c	7 Oct 2005 17:42:50 -0000	1.134
+++ ldtp.c	7 Oct 2005 18:14:15 -0000
@@ -2201,31 +2201,76 @@ static PyObject *select_calendar_date (P
 static PyObject *remap (PyObject *self, PyObject *args)
 {
   Accessible *context;
-  char *app_name = NULL;
   GHashTable *new_hashtable;
+  GHashTable *dialog_attributes;
+  char *application_name;
+  char *msg;
 
-  if (!PyArg_ParseTuple (args, "ss", &app_name, &window_name))
+  /*
+   * The first argument is not being used currently. It has been
included
+   * just to handle the case in the future where appmaps of multiple
applications
+   * will be maintained at the same time.
+   */
+  if (!PyArg_ParseTuple (args, "ss", &application_name, &window_name))
     return PyErr_Format (ldtp_error, "%s %s %d", "Argument missing /
invalid", __FILE__, __LINE__);
     
   context = get_gui_handle (appmap, window_name, window_name);
   if (!context)
     {
-      g_print ("Unable to get context handle!\n");
+      char *msg;
+      msg = g_strdup_printf ("Unable to retain dialog attributes from
existing appmap!!");
+      if (msg)
+	{
+	  g_print ("%s", msg);
+	  log_msg (LOG_CAUSE, msg);
+	  g_free (msg);
+	}
       return Py_BuildValue ("i", 0);
     }
-  new_hashtable = do_remap (app_name, context);
 
   old_contextmap = (GHashTable *) g_hash_table_lookup (appmap,
window_name);
-  g_hash_table_insert (appmap, window_name, new_hashtable);
+  dialog_attributes = g_hash_table_lookup (old_contextmap,
window_name);
+  if (dialog_attributes)
+    new_hashtable = do_remap (context, window_name, dialog_attributes);
+  else
+    {
+      msg = g_strdup_printf ("Unable to retain dialog attributes from
existing appmap!!");
+      if (msg)
+	{
+	  g_print ("%s", msg);
+	  log_msg (LOG_CAUSE, msg);
+	  g_free (msg);
+	}
+      return Py_BuildValue ("i", 0);
+    }
   Accessible_unref (context);
+  if (new_hashtable)
+    g_hash_table_insert (appmap, window_name, new_hashtable);
+  else
+    {
+      msg = g_strdup_printf ("NULL returned from remap!!");
+      if (msg)
+	{
+	  g_print ("%s", msg);
+	  log_msg (LOG_CAUSE, msg);
+	  g_free (msg);
+	}
+      return Py_BuildValue ("i", 0);
+    }
   return Py_BuildValue ("i", 1);
 }
 
 static PyObject *undo_remap (PyObject *self, PyObject *args)
 {
   GHashTable *new_hashtable;
+  char *application_name;
 
-  if (!PyArg_ParseTuple (args, "s", &window_name))
+  /*
+   * The first argument is not being used currently. It has been
included
+   * just to handle the case in the future where appmaps of multiple
applications
+   * will be maintained at the same time.
+   */
+  if (!PyArg_ParseTuple (args, "ss", &application_name, &window_name))
     return PyErr_Format (ldtp_error, "%s %s %d", "Argument missing /
invalid", __FILE__, __LINE__);
 
   new_hashtable = g_hash_table_lookup (appmap, window_name);
Index: ldtp.h
===================================================================
RCS file: /cvs/pyldtp/ldtp.h,v
retrieving revision 1.19
diff -u -p -r1.19 ldtp.h
--- ldtp.h	23 Sep 2005 18:56:45 -0000	1.19
+++ ldtp.h	7 Oct 2005 18:14:15 -0000
@@ -119,6 +119,6 @@ int tree_table_main(Accessible *object, 
 int tool_bar_main (Accessible *object, int command, char **params);
 
 //remap.c
-GHashTable *do_remap (char *app_name, Accessible *object);
+GHashTable *do_remap (Accessible *object, char *name, GHashTable
*context_attrubutes);
 
 #endif /*_LDTP_H_*/
Index: remap.c
===================================================================
RCS file: /cvs/pyldtp/remap.c,v
retrieving revision 1.4
diff -u -p -r1.4 remap.c
--- remap.c	6 Oct 2005 13:19:43 -0000	1.4
+++ remap.c	7 Oct 2005 18:14:15 -0000
@@ -580,12 +580,18 @@ OBJECT_INFO *get_object_info (Accessible
   return obj_info;
 }
 
-GHashTable *do_remap (char *application_name, Accessible
*accessible_context)
+GHashTable *do_remap (Accessible *accessible_context, char *name,
GHashTable *context_attributes)
 {
   GHashTable *current_context = NULL;
   reset_count ();
+
   current_context = g_hash_table_new (&g_str_hash, &g_str_equal);
-  accessible_object_handle (accessible_context, application_name, 0,
current_context);
+  g_hash_table_insert (current_context, g_strdup (name),
context_attributes);
+  /*
+   * NOTE: Passing -1 as parameter signifies that the first entry has
+   * already been added, so should not do add_appmap_data for this call
+   */
+  accessible_object_handle (accessible_context, g_strdup (name), -1,
current_context);
   return current_context;
 }
 
@@ -601,7 +607,10 @@ void accessible_object_handle (Accessibl
   char *temp_parent = NULL;
 
   num_child = Accessible_getChildCount (accessible);
-  temp_parent = add_appmap_data (accessible, parent_name, child_index,
current_context);
+  if (child_index != -1)
+    temp_parent = add_appmap_data (accessible, parent_name,
child_index, current_context);
+  else
+    temp_parent = parent_name;
   if (temp_parent)
     {
       current_parent = g_strdup (temp_parent);
Index: remap.h
===================================================================
RCS file: /cvs/pyldtp/remap.h,v
retrieving revision 1.3
diff -u -p -r1.3 remap.h
--- remap.h	27 Sep 2005 13:21:41 -0000	1.3
+++ remap.h	7 Oct 2005 18:14:15 -0000
@@ -27,7 +27,7 @@
 
 void reset_count (void);
 char *add_appmap_data (Accessible *accessible, char *parent_name, int
child_index, GHashTable *context); 
-GHashTable *do_remap (char *application_name, Accessible *accessible); 
+GHashTable *do_remap (Accessible *accessible, char *name, GHashTable
*context_attributes); 
 void accessible_object_handle (Accessible *accessible, char
*parent_name, int child_index, GHashTable *context); 
 OBJECT_INFO *get_object_info (Accessible *accessible);
 int filter_appmap_data (Accessible *accessible, OBJECT_INFO *cur_obj,
char *label);



More information about the Ldtp-dev mailing list