summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-11-16 10:15:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-11-16 10:15:58 (GMT)
commitc613f485dec9f480ba1acde233272b75cb7c11c9 (patch)
treea700fea628c981b5df624bd6506eefa4b02d7985 /src
parent72ed953e6bf4c93057aadac5bb49d7633658273b (diff)
Warned about unsaved projects only if needed.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/project.c52
-rw-r--r--src/analysis/project.h6
-rw-r--r--src/gui/editor.c2
3 files changed, 59 insertions, 1 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c
index 8285e7a..e0624f2 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -715,6 +715,58 @@ void g_study_project_detach_content(GStudyProject *project, GLoadedContent *cont
/******************************************************************************
* *
* Paramètres : project = projet dont le contenu est à afficher. *
+* *
+* Description : Dénombre les contenus associés à un projet. *
+* *
+* Retour : Nombre de contenus pris en compte. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+size_t _g_study_project_count_contents(GStudyProject *project)
+{
+ size_t result; /* Quantité à retourner */
+
+ assert(!g_mutex_trylock(&project->mutex));
+
+ result = project->count;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : project = projet dont le contenu est à afficher. *
+* *
+* Description : Dénombre les contenus associés à un projet. *
+* *
+* Retour : Nombre de contenus pris en compte. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+size_t g_study_project_count_contents(GStudyProject *project)
+{
+ size_t result; /* Quantité à retourner */
+
+ g_study_project_lock_contents(project);
+
+ result = _g_study_project_count_contents(project);
+
+ g_study_project_unlock_contents(project);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : project = projet dont le contenu est à afficher. *
* count = nombre de contenus pris en compte. [OUT] *
* *
* Description : Fournit l'ensemble des contenus associés à un projet. *
diff --git a/src/analysis/project.h b/src/analysis/project.h
index 7ec6239..e627041 100644
--- a/src/analysis/project.h
+++ b/src/analysis/project.h
@@ -98,6 +98,12 @@ void g_study_project_attach_content(GStudyProject *, GLoadedContent *);
/* Détache un contenu donné d'un projet donné. */
void g_study_project_detach_content(GStudyProject *, GLoadedContent *);
+/* Dénombre les contenus associés à un projet. */
+size_t _g_study_project_count_contents(GStudyProject *);
+
+/* Dénombre les contenus associés à un projet. */
+size_t g_study_project_count_contents(GStudyProject *);
+
/* Fournit l'ensemble des contenus associés à un projet. */
GLoadedContent **_g_study_project_get_contents(GStudyProject *, size_t *);
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 8280e7c..42c1f77 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -344,7 +344,7 @@ static gboolean on_delete_editor(GtkWidget *widget, GdkEvent *event, gpointer da
project = get_current_project();
- if (g_study_project_get_filename(project) == NULL)
+ if (g_study_project_get_filename(project) == NULL && g_study_project_count_contents(project) > 0)
{
dialog = gtk_message_dialog_new(GTK_WINDOW(widget),
GTK_DIALOG_DESTROY_WITH_PARENT,