[anjuta/system-db-refactor: 21/22] language-support-cpp-java: Fix scanning of user-defined packages
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/system-db-refactor: 21/22] language-support-cpp-java: Fix scanning of user-defined packages
- Date: Thu, 3 Mar 2011 16:40:10 +0000 (UTC)
commit 51e15dff6c97ea071892f40391737122faeadfd3
Author: Johannes Schmid <jhs gnome org>
Date: Thu Mar 3 17:35:31 2011 +0100
language-support-cpp-java: Fix scanning of user-defined packages
plugins/language-support-cpp-java/cpp-packages.c | 105 ++++++++++++++--------
plugins/language-support-cpp-java/cpp-packages.h | 1 +
2 files changed, 68 insertions(+), 38 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/cpp-packages.c b/plugins/language-support-cpp-java/cpp-packages.c
index 97cf158..e6f614c 100644
--- a/plugins/language-support-cpp-java/cpp-packages.c
+++ b/plugins/language-support-cpp-java/cpp-packages.c
@@ -244,31 +244,33 @@ cpp_packages_load_real (CppPackages* packages, GError* error, IAnjutaProjectMana
return;
ianjuta_symbol_manager_deactivate_all (sm, NULL);
- packages->loading = TRUE;
-
pkgs = ianjuta_project_manager_get_packages (pm, NULL);
for (pkg = pkgs; pkg != NULL; pkg = g_list_next (pkg))
{
cpp_packages_activate_package (sm, pkg->data, &packages_to_add);
}
g_list_free (pkgs);
- packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
- for (pkg = packages_to_add; pkg != NULL; pkg = g_list_next (pkg))
+ if (packages_to_add)
{
- PackageData* pkg_data = pkg->data;
- AnjutaCommand* command =
- anjuta_pkg_scanner_new (pkg_data->pkg, pkg_data->version);
- g_signal_connect (command, "command-finished",
- G_CALLBACK (on_package_ready), sm);
- anjuta_command_queue_push (packages->queue, command);
- }
- g_list_foreach (packages_to_add, (GFunc) pkg_data_free, NULL);
- g_list_free (packages_to_add);
+ packages->loading = TRUE;
+ packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
+ for (pkg = packages_to_add; pkg != NULL; pkg = g_list_next (pkg))
+ {
+ PackageData* pkg_data = pkg->data;
+ AnjutaCommand* command =
+ anjuta_pkg_scanner_new (pkg_data->pkg, pkg_data->version);
+ g_signal_connect (command, "command-finished",
+ G_CALLBACK (on_package_ready), sm);
+ anjuta_command_queue_push (packages->queue, command);
+ }
+ g_list_foreach (packages_to_add, (GFunc) pkg_data_free, NULL);
+ g_list_free (packages_to_add);
- g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), packages);
- /* Make sure the pointer is valid when the queue finishes */
- g_object_ref (packages);
- anjuta_command_queue_start (packages->queue);
+ g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), packages);
+ /* Make sure the pointer is valid when the queue finishes */
+ g_object_ref (packages);
+ anjuta_command_queue_start (packages->queue);
+ }
}
static void
@@ -281,7 +283,7 @@ cpp_packages_load_user (CppPackages* packages, gboolean force)
gboolean loaded = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (shell),
USER_LOADED));
- if (!loaded && !force)
+ if (!loaded || force)
{
gchar* packages_str = g_settings_get_string (plugin->settings,
PREF_USER_PACKAGES);
@@ -289,8 +291,6 @@ cpp_packages_load_user (CppPackages* packages, gboolean force)
gchar** package;
GList* packages_to_add = NULL;
GList* pkg;
-
- packages->loading = TRUE;
ianjuta_symbol_manager_deactivate_all (sm, NULL);
@@ -302,29 +302,46 @@ cpp_packages_load_user (CppPackages* packages, gboolean force)
g_strfreev (pkgs);
g_free (packages_str);
- packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
- for (pkg = packages_to_add; pkg != NULL; pkg = g_list_next (pkg))
+ if (packages_to_add)
{
- PackageData* pkg_data = pkg->data;
- AnjutaCommand* command =
- anjuta_pkg_scanner_new (pkg_data->pkg, pkg_data->version);
- g_signal_connect (command, "command-finished",
- G_CALLBACK (on_package_ready), sm);
- anjuta_command_queue_push (packages->queue, command);
- }
- g_list_foreach (packages_to_add, (GFunc) pkg_data_free, NULL);
- g_list_free (packages_to_add);
+ packages->loading = TRUE;
+ packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
+ for (pkg = packages_to_add; pkg != NULL; pkg = g_list_next (pkg))
+ {
+ PackageData* pkg_data = pkg->data;
+ AnjutaCommand* command =
+ anjuta_pkg_scanner_new (pkg_data->pkg, pkg_data->version);
+ g_signal_connect (command, "command-finished",
+ G_CALLBACK (on_package_ready), sm);
+ anjuta_command_queue_push (packages->queue, command);
+ }
+ g_list_foreach (packages_to_add, (GFunc) pkg_data_free, NULL);
+ g_list_free (packages_to_add);
- g_object_set_data (G_OBJECT (shell),
- USER_LOADED, GINT_TO_POINTER (TRUE));
+ g_object_set_data (G_OBJECT (shell),
+ USER_LOADED, GINT_TO_POINTER (TRUE));
- g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), packages);
- /* Make sure the pointer is valid when the queue finishes */
- g_object_ref (packages);
- anjuta_command_queue_start (packages->queue);
+ g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), packages);
+ /* Make sure the pointer is valid when the queue finishes */
+ g_object_ref (packages);
+ anjuta_command_queue_start (packages->queue);
+ }
}
}
+static gboolean
+cpp_packages_idle_load_user (CppPackages* packages)
+{
+ if (packages->loading)
+ return TRUE;
+
+ cpp_packages_load (packages, TRUE);
+ packages->idle_id = 0;
+ g_object_unref (packages);
+
+ return FALSE;
+}
+
void
cpp_packages_load (CppPackages* packages, gboolean force)
{
@@ -355,8 +372,19 @@ cpp_packages_load (CppPackages* packages, gboolean force)
else
{
if (packages->loading)
+ {
+ if (!packages->idle_id)
+ {
+ packages->idle_id = g_idle_add ((GSourceFunc)cpp_packages_idle_load_user, packages);
+ g_object_ref (packages);
+ }
return;
- cpp_packages_load_user (packages, force);
+ }
+ else
+ {
+ g_message ("Loading user packages");
+ cpp_packages_load_user (packages, force);
+ }
}
g_signal_connect (plugin->settings, "changed::PREF_LIBC",
@@ -370,6 +398,7 @@ static void
cpp_packages_init (CppPackages *packages)
{
packages->loading = FALSE;
+ packages->idle_id = 0;
}
static void
diff --git a/plugins/language-support-cpp-java/cpp-packages.h b/plugins/language-support-cpp-java/cpp-packages.h
index f114874..4da8eda 100644
--- a/plugins/language-support-cpp-java/cpp-packages.h
+++ b/plugins/language-support-cpp-java/cpp-packages.h
@@ -47,6 +47,7 @@ struct _CppPackages
AnjutaPlugin* plugin;
AnjutaCommandQueue* queue;
gboolean loading;
+ guint idle_id;
};
GType cpp_packages_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]