[gnumeric] Fix warning on exit when clipboard is active.



commit 738073c75f3697bd57058308d79bce95aa9976db
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 22 11:00:55 2009 -0400

    Fix warning on exit when clipboard is active.
---
 ChangeLog     |    2 ++
 src/wbc-gtk.c |   10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bd14c3c..89ab960 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2009-04-22  Morten Welinder  <terra gnome org>
 
+	* src/wbc-gtk.c (wbcg_get_scg): Fix warning on exit.
+
 	* src/workbook.c (workbook_sheets): Change result type to GSList*.
 	All callers changed.
 
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 719688b..f56d841 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -175,6 +175,15 @@ wbcg_get_scg (WBCGtk *wbcg, Sheet *sheet)
 	if (sheet == NULL || wbcg->snotebook == NULL)
 		return NULL;
 
+	npages = wbcg_get_n_scg (wbcg);
+	if (npages == 0) {
+		/*
+		 * This can happen during construction when the clipboard is
+		 * being cleared.  Ctrl-C Ctrl-Q.
+		 */
+		return NULL;
+	}
+
 	g_return_val_if_fail (IS_SHEET (sheet), NULL);
 	g_return_val_if_fail (sheet->index_in_wb >= 0, NULL);
 
@@ -186,7 +195,6 @@ wbcg_get_scg (WBCGtk *wbcg, Sheet *sheet)
 	 * index_in_wb is probably not accurate because we are in the
 	 * middle of removing or adding a sheet.
 	 */
-	npages = wbcg_get_n_scg (wbcg);
 	for (i = 0; i < npages; i++) {
 		scg = wbcg_get_nth_scg (wbcg, i);
 		if (NULL != scg && scg_sheet (scg) == sheet)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]