Commit 9d117084 authored by Sebastien Granjoux's avatar Sebastien Granjoux

am: Fix autotools autotest after merging master branch and using thread

parent b4917637
......@@ -2273,6 +2273,12 @@ amp_project_add_file (AmpProject *project, GFile *file, AnjutaTokenFile* token)
g_object_add_toggle_ref (G_OBJECT (token), remove_config_file, project);
}
gboolean
amp_project_is_busy (AmpProject *project)
{
return pm_command_queue_is_busy (project->queue);
}
/* Worker thread
*---------------------------------------------------------------------------*/
......@@ -2281,7 +2287,7 @@ amp_load_setup (PmJob *job)
{
job->parent = anjuta_project_node_parent (job->node);
job->proxy = amp_project_duplicate_node (job->node);
g_message ("type %x proxy %x parent %p node %p proxy %p", job->node->type, job->proxy->type, job->parent, job->node, job->proxy);
// g_message ("amp_load_setup type %x proxy %x parent %p node %p proxy %p", job->node->type, job->proxy->type, job->parent, job->node, job->proxy);
return TRUE;
}
......@@ -2300,7 +2306,7 @@ amp_load_complete (PmJob *job)
GHashTable *map;
map = amp_project_map_node (job->node, job->proxy);
g_message ("type %x proxy %x", job->node->type, job->proxy->type);
// g_message ("amp_load_complete type %x proxy %x", job->node->type, job->proxy->type);
g_hash_table_foreach (map, (GHFunc)amp_project_replace_node, map);
job->node->parent = job->parent;
job->proxy->parent = NULL;
......
......@@ -100,6 +100,8 @@ gboolean amp_project_dump (AmpProject *project, AnjutaProjectNode *node);
gchar * amp_project_get_uri (AmpProject *project);
GFile* amp_project_get_file (AmpProject *project);
gboolean amp_project_is_busy (AmpProject *project);
void amp_project_add_file (AmpProject *project, GFile *file, AnjutaTokenFile* token);
AnjutaAmGroupNode* amp_project_add_group (AmpProject *project, AnjutaAmGroupNode *parent, const gchar *name, GError **error);
......
......@@ -139,116 +139,6 @@ static gboolean pm_command_queue_idle (PmCommandQueue *queue);
/* Worker thread functions
*---------------------------------------------------------------------------*/
static gint
pm_project_compare_node (AnjutaProjectNode *old_node, AnjutaProjectNode *new_node)
{
gchar *name1;
gchar *name2;
GFile *file1;
GFile *file2;
name1 = anjuta_project_node_get_name (old_node);
name2 = anjuta_project_node_get_name (new_node);
file1 = anjuta_project_node_get_file (old_node);
file2 = anjuta_project_node_get_file (new_node);
return (anjuta_project_node_get_node_type (old_node) == anjuta_project_node_get_node_type (new_node))
&& ((name1 == NULL) || (name2 == NULL) || (strcmp (name1, name2) == 0))
&& ((file1 == NULL) || (file2 == NULL) || g_file_equal (file1, file2)) ? 0 : 1;
}
static void
pm_project_map_children (PmJob *job, AnjutaProjectNode *old_node, AnjutaProjectNode *new_node)
{
GList *children = NULL;
if (new_node != NULL)
{
for (new_node = anjuta_project_node_first_child (new_node); new_node != NULL; new_node = anjuta_project_node_next_sibling (new_node))
{
children = g_list_prepend (children, new_node);
}
children = g_list_reverse (children);
}
for (old_node = anjuta_project_node_first_child (old_node); old_node != NULL; old_node = anjuta_project_node_next_sibling (old_node))
{
GList *same;
same = g_list_find_custom (children, old_node, (GCompareFunc)pm_project_compare_node);
if (same != NULL)
{
g_hash_table_insert (job->map, old_node, (AnjutaProjectNode *)same->data);
pm_project_map_children ((PmJob *)job, old_node, (AnjutaProjectNode *)same->data);
children = g_list_delete_link (children, same);
}
else
{
/* Mark deleted node */
g_hash_table_insert (job->map, old_node, NULL);
pm_project_map_children ((PmJob *)job, old_node, NULL);
}
}
g_list_free (children);
}
static void
pm_project_map_node (PmJob *job)
{
if ((job->proxy != NULL) && (job->node != NULL))
{
AnjutaProjectNode *old_node;
AnjutaProjectNode *new_node;
job->map = g_hash_table_new (g_direct_hash, NULL);
old_node = job->proxy;
new_node = job->node;
g_hash_table_insert (job->map, old_node, new_node);
pm_project_map_children (job, old_node, new_node);
}
}
#if 0
static gboolean
pm_command_load_work (AnjutaPmProject *project, PmJob *job)
{
AnjutaProjectNode *node;
if (ianjuta_project_load_node (project->project, job->node, &(job->error)))
{
pm_project_map_node (job);
}
return TRUE;
}
static gboolean
pm_command_save_work (AnjutaPmProject *project, PmJob *job)
{
return ianjuta_project_save_node (project->project, job->node, &(job->error));
}
static gboolean
pm_command_exit_work (AnjutaPmProject *project, PmJob *job)
{
g_return_val_if_fail (job != NULL, FALSE);
/* Push job in complete queue as g_thread_exit will stop the thread
* immediatly */
g_async_queue_push (project->done_queue, job);
g_thread_exit (0);
return TRUE;
}
#endif
/* Run work function in worker thread */
static gpointer
pm_command_queue_thread_main_loop (PmCommandQueue *queue)
......@@ -463,6 +353,13 @@ pm_command_queue_push (PmCommandQueue *queue, PmJob *job)
pm_command_queue_run_command (queue);
}
gboolean
pm_command_queue_is_busy (PmCommandQueue *queue)
{
g_message ("pm_command_queue_is_empty %d %d %d busy %d", g_queue_get_length (queue->job_queue), g_async_queue_length(queue->work_queue), g_async_queue_length(queue->done_queue), queue->busy);
return queue->busy;
}
PmCommandQueue*
pm_command_queue_new (void)
{
......
......@@ -66,7 +66,7 @@ PmCommandQueue* pm_command_queue_new (void);
void pm_command_queue_free (PmCommandQueue *queue);
void pm_command_queue_push (PmCommandQueue *queue, PmJob *job);
gboolean pm_command_queue_is_busy (PmCommandQueue *queue);
G_END_DECLS
......
......@@ -401,6 +401,15 @@ get_project_property (IAnjutaProject *project, AnjutaProjectNode *parent, const
return prop;
}
static void
amp_project_wait_ready (IAnjutaProject *project)
{
while (amp_project_is_busy (AMP_PROJECT (project)))
{
g_main_context_iteration (NULL, TRUE);
}
}
/* Automake parsing function
*---------------------------------------------------------------------------*/
......@@ -642,6 +651,7 @@ main(int argc, char *argv[])
break;
}
amp_project_wait_ready (project);
if (error != NULL)
{
fprintf (stderr, "Error: %s\n", error->message == NULL ? "unknown error" : error->message);
......@@ -654,6 +664,6 @@ main(int argc, char *argv[])
/* Free objects */
if (project) g_object_unref (project);
close_output ();
return (0);
}
This diff is collapsed.
......@@ -46,7 +46,7 @@ AC_CONFIG_FILES(Makefile)
]])
AT_PARSER_CHECK([load empty1 \
move empty2 \
add package 0 package2 after 0:1\
add package 0 package2 after 0:0\
list \
save])
AT_CHECK([[sed 's/^\(\s*\w\+\s*(\)[0-9:]\+\()\)/\1\2/' output | diff - expect]])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment