summaryrefslogtreecommitdiff
path: root/src/analysis/project.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-11-25 23:18:38 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-11-25 23:18:38 (GMT)
commit0daafbb6b4c0e845f9e61a28adb0a68bb2d0b582 (patch)
tree1333a2c38cb6c0b6f1c6267898cbf266e91698b8 /src/analysis/project.c
parent431fe9cf106ed205dd26dc9a6e1ec542c8fed7f8 (diff)
Displayed and hidden loaded contents on project change.
Diffstat (limited to 'src/analysis/project.c')
-rw-r--r--src/analysis/project.c109
1 files changed, 48 insertions, 61 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c
index 4a15ea0..4399fc4 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -257,7 +257,7 @@ static void g_study_project_dispose(GStudyProject *project)
{
size_t i; /* Boucle de parcours */
- g_mutex_lock(&project->mutex);
+ g_study_project_lock_contents(project);
for (i = 0; i < project->count; i++)
g_object_unref(G_OBJECT(project->contents[i]));
@@ -265,7 +265,7 @@ static void g_study_project_dispose(GStudyProject *project)
if (project->contents != NULL)
free(project->contents);
- g_mutex_unlock(&project->mutex);
+ g_study_project_unlock_contents(project);
g_mutex_clear(&project->mutex);
@@ -400,7 +400,7 @@ bool g_study_project_save(GStudyProject *project, const char *filename)
root_count = 0;
- g_mutex_lock(&project->mutex);
+ g_study_project_lock_contents(project);
for (i = 0; i < project->count && result; i++)
{
@@ -469,7 +469,7 @@ bool g_study_project_save(GStudyProject *project, const char *filename)
}
- g_mutex_unlock(&project->mutex);
+ g_study_project_unlock_contents(project);
/* Sauvegarde finale */
@@ -602,6 +602,29 @@ static void on_loaded_content_analyzed(GLoadedContent *content, gboolean success
/******************************************************************************
* *
* Paramètres : project = project à manipuler. *
+* lock = sélection du type de traitement à opérer. *
+* *
+* Description : Verrouille ou déverrouille l'accès aux contenus chargés. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void _g_study_project_lock_unlock_contents(GStudyProject *project, bool lock)
+{
+ if (lock)
+ g_mutex_lock(&project->mutex);
+ else
+ g_mutex_unlock(&project->mutex);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : project = project à manipuler. *
* content = contenu chargé à associer au projet actuel. *
* *
* Description : Attache un contenu donné à un projet donné. *
@@ -614,7 +637,7 @@ static void on_loaded_content_analyzed(GLoadedContent *content, gboolean success
void g_study_project_attach_content(GStudyProject *project, GLoadedContent *content)
{
- g_mutex_lock(&project->mutex);
+ g_study_project_lock_contents(project);
project->contents = (GLoadedContent **)realloc(project->contents,
++project->count * sizeof(GLoadedContent *));
@@ -622,7 +645,7 @@ void g_study_project_attach_content(GStudyProject *project, GLoadedContent *cont
project->contents[project->count - 1] = content;
g_object_ref(G_OBJECT(content));
- g_mutex_unlock(&project->mutex);
+ g_study_project_unlock_contents(project);
g_signal_emit_by_name(project, "content-added", content);
@@ -646,7 +669,7 @@ void g_study_project_detach_content(GStudyProject *project, GLoadedContent *cont
{
size_t i; /* Boucle de parcours */
- g_mutex_lock(&project->mutex);
+ g_study_project_lock_contents(project);
for (i = 0; i < project->count; i++)
if (project->contents[i] == content) break;
@@ -658,7 +681,7 @@ void g_study_project_detach_content(GStudyProject *project, GLoadedContent *cont
project->contents = (GLoadedContent **)realloc(project->contents,
--project->count * sizeof(GLoadedContent *));
- g_mutex_unlock(&project->mutex);
+ g_study_project_unlock_contents(project);
g_signal_emit_by_name(project, "content-removed", content);
@@ -670,62 +693,34 @@ void g_study_project_detach_content(GStudyProject *project, GLoadedContent *cont
/******************************************************************************
* *
* Paramètres : project = projet dont le contenu est à afficher. *
+* count = nombre de contenus pris en compte. [OUT] *
* *
-* Description : Met en place un projet à l'écran. *
+* Description : Fournit l'ensemble des contenus associés à un projet. *
* *
-* Retour : - *
+* Retour : Liste à libérer de la mémoire. *
* *
* Remarques : - *
* *
******************************************************************************/
-void g_study_project_display(const GStudyProject *project)
+GLoadedContent **_g_study_project_get_contents(GStudyProject *project, size_t *count)
{
-#if 0
- size_t i; /* Boucle de parcours #1 */
- loaded_binary *handled; /* Binaire prise en compte */
- size_t j; /* Boucle de parcours #2 */
-
- for (i = 0; i < project->binaries_count; i++)
- {
- handled = project->binaries[i];
-
- for (j = 0; j < handled->count; j++)
- g_panel_item_dock(handled->items[j]);
-
- }
-#endif
-}
-
+ GLoadedContent **result; /* Tableau à retourner */
+ size_t i; /* Boucle de parcours */
-/******************************************************************************
-* *
-* Paramètres : project = projet dont le contenu est à cacher. *
-* *
-* Description : Supprime de l'écran un projet en place. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ assert(!g_mutex_trylock(&project->mutex));
-void g_study_project_hide(const GStudyProject *project)
-{
-#if 0
- size_t i; /* Boucle de parcours #1 */
- loaded_binary *handled; /* Binaire prise en compte */
- size_t j; /* Boucle de parcours #2 */
+ *count = project->count;
+ result = malloc(*count * sizeof(GLoadedContent *));
- for (i = 0; i < project->binaries_count; i++)
+ for (i = 0; i < *count; i++)
{
- handled = project->binaries[i];
+ result[i] = project->contents[i];
+ g_object_ref(G_OBJECT(result[i]));
+ }
- for (j = 0; j < handled->count; j++)
- g_panel_item_undock(handled->items[j]);
+ return result;
- }
-#endif
}
@@ -745,20 +740,12 @@ void g_study_project_hide(const GStudyProject *project)
GLoadedContent **g_study_project_get_contents(GStudyProject *project, size_t *count)
{
GLoadedContent **result; /* Tableau à retourner */
- size_t i; /* Boucle de parcours */
- g_mutex_lock(&project->mutex);
+ g_study_project_lock_contents(project);
- *count = project->count;
- result = (GLoadedContent **)calloc(*count, sizeof(GLoadedContent *));
-
- for (i = 0; i < *count; i++)
- {
- result[i] = project->contents[i];
- g_object_ref(G_OBJECT(result[i]));
- }
+ result = _g_study_project_get_contents(project, count);
- g_mutex_unlock(&project->mutex);
+ g_study_project_unlock_contents(project);
return result;