summaryrefslogtreecommitdiff
path: root/src/analysis/project.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/project.c')
-rw-r--r--src/analysis/project.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c
index 4574d88..6156fbc 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -67,7 +67,7 @@ struct _GStudyProjectClass
/* Signaux */
- void (* contents_available) (GStudyProject, GLoadedContent **, guint);
+ void (* contents_available) (GStudyProject, GLoadedContent *);
void (* content_added) (GStudyProject *, GLoadedContent *);
void (* content_removed) (GStudyProject *, GLoadedContent *);
@@ -202,13 +202,13 @@ static void g_study_project_class_init(GStudyProjectClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_study_project_dispose;
object->finalize = (GObjectFinalizeFunc)g_study_project_finalize;
- g_signal_new("contents-available",
+ g_signal_new("content-available",
G_TYPE_STUDY_PROJECT,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GStudyProjectClass, contents_available),
NULL, NULL,
- g_cclosure_user_marshal_VOID__POINTER_UINT,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_signal_new("content-added",
G_TYPE_STUDY_PROJECT,
@@ -610,7 +610,14 @@ void on_loaded_content_analyzed(GLoadedContent *content, gboolean success, GStud
else
log_variadic_message(LMT_ERROR, _("Failed to load '%s'"), desc);
- g_object_ref(G_OBJECT(content));
+ /**
+ * Le contenu a normalement été sur-référencé pour ne pas disparaître
+ * en cours d'analyse.
+ *
+ * On revient donc à une situation nominale ici.
+ */
+
+ g_object_unref(G_OBJECT(content));
}
@@ -655,8 +662,7 @@ void g_study_project_attach_content(GStudyProject *project, GLoadedContent *cont
{
g_study_project_lock_contents(project);
- project->contents = (GLoadedContent **)realloc(project->contents,
- ++project->count * sizeof(GLoadedContent *));
+ project->contents = realloc(project->contents, ++project->count * sizeof(GLoadedContent *));
project->contents[project->count - 1] = content;
g_object_ref(G_OBJECT(content));
@@ -1208,12 +1214,12 @@ static void on_new_content_explored(GContentExplorer *explorer, wgroup_id_t wid,
g_object_unref(G_OBJECT(resolver));
for (i = 0; i < count; i++)
- g_object_unref(G_OBJECT(available[i]));
+ g_object_unref(G_OBJECT(available[i]));
free(available);
for (i = 0; i < noted; i++)
- g_object_unref(G_OBJECT(detected[i]));
+ g_object_unref(G_OBJECT(detected[i]));
if (detected != NULL)
free(detected);
@@ -1241,7 +1247,6 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
{
GLoadedContent **available; /* Contenus chargés valables */
size_t count; /* Quantité de ces contenus */
- bool keep; /* Conservation finale de liste*/
size_t i; /* Boucle de parcours */
GBinContent *content; /* Contenu brut à manipuler */
const gchar *hash; /* Empreinte d'un contenu */
@@ -1254,8 +1259,6 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
{
available = g_content_resolver_get_all(resolver, wid, &count);
- keep = false;
-
/* Rechargement à partir d'XML ? */
if (handler->xdoc != NULL)
{
@@ -1316,25 +1319,21 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
/* Découverte(s) initiale(s) ? */
else
{
- for (i = 0; i < count; i++)
- {
- /**
- * S'il s'agit des résultats de la dernière exploration,
- * alors les groupes contenant les éléments chargés vont
- * être libéré, potentiellement pendant l'analyse.
- *
- * On temporise en incrémentant les références.
- */
- g_object_ref(G_OBJECT(available[i]));
-
- }
-
if (is_batch_mode())
{
for (i = 0; i < count; i++)
{
if (handler->filter == NULL || handler->filter(available[i], handler->data))
{
+ /**
+ * S'il s'agit des résultats de la dernière exploration,
+ * alors les groupes contenant les éléments chargés vont
+ * être libéré, potentiellement pendant l'analyse.
+ *
+ * On temporise en incrémentant les références.
+ */
+ g_object_ref(G_OBJECT(available[i]));
+
g_signal_connect(available[i], "analyzed",
G_CALLBACK(on_loaded_content_analyzed), handler->project);
@@ -1349,17 +1348,16 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid,
}
else
- {
- g_signal_emit_by_name(handler->project, "contents-available", available, count);
-
- keep = true;
-
- }
+ for (i = 0; i < count; i++)
+ {
+ g_signal_emit_by_name(handler->project, "content-available", available[i]);
+ g_object_unref(G_OBJECT(available[i]));
+ }
}
/* Dans tous les cas... */
- if (available != NULL && !keep)
+ if (available != NULL)
free(available);
/* Si c'était la dernière résolution... */