[evince] [libdocument] Protect some public methods with g_return macros
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evince] [libdocument] Protect some public methods with g_return macros
- Date: Tue, 15 Sep 2009 14:10:50 +0000 (UTC)
commit e3aaabdfd3f236f4e050686662e058d8288d8c2a
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Wed Aug 19 15:41:07 2009 +0200
[libdocument] Protect some public methods with g_return macros
libdocument/ev-document.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index a74a0e3..c2c73aa 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -352,6 +352,8 @@ _ev_document_get_n_pages (EvDocument *document)
gint
ev_document_get_n_pages (EvDocument *document)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), 0);
+
return document->priv->n_pages;
}
@@ -372,6 +374,9 @@ ev_document_get_page_size (EvDocument *document,
double *width,
double *height)
{
+ g_return_if_fail (EV_IS_DOCUMENT (document));
+ g_return_if_fail (page_index >= 0 || page_index < document->priv->n_pages);
+
if (width)
*width = document->priv->uniform ?
document->priv->uniform_width :
@@ -396,6 +401,9 @@ gchar *
ev_document_get_page_label (EvDocument *document,
gint page_index)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
+ g_return_val_if_fail (page_index >= 0 || page_index < document->priv->n_pages, NULL);
+
return (document->priv->page_labels && document->priv->page_labels[page_index]) ?
g_strdup (document->priv->page_labels[page_index]) :
g_strdup_printf ("%d", page_index + 1);
@@ -412,6 +420,8 @@ _ev_document_get_info (EvDocument *document)
EvDocumentInfo *
ev_document_get_info (EvDocument *document)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
+
return document->priv->info;
}
@@ -427,6 +437,8 @@ ev_document_render (EvDocument *document,
const gchar *
ev_document_get_title (EvDocument *document)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
+
return (document->priv->info->fields_mask & EV_DOCUMENT_INFO_TITLE) ?
document->priv->info->title : NULL;
}
@@ -434,6 +446,8 @@ ev_document_get_title (EvDocument *document)
gboolean
ev_document_is_page_size_uniform (EvDocument *document)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), TRUE);
+
return document->priv->uniform;
}
@@ -442,6 +456,8 @@ ev_document_get_max_page_size (EvDocument *document,
gdouble *width,
gdouble *height)
{
+ g_return_if_fail (EV_IS_DOCUMENT (document));
+
if (width)
*width = document->priv->max_width;
if (height)
@@ -451,12 +467,16 @@ ev_document_get_max_page_size (EvDocument *document,
gint
ev_document_get_max_label_len (EvDocument *document)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), -1);
+
return document->priv->max_label;
}
gboolean
ev_document_has_text_page_labels (EvDocument *document)
{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
+
return document->priv->page_labels != NULL;
}
@@ -470,6 +490,10 @@ ev_document_find_page_by_label (EvDocument *document,
gchar *endptr = NULL;
EvDocumentPrivate *priv = document->priv;
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
+ g_return_val_if_fail (page_label != NULL, FALSE);
+ g_return_val_if_fail (page_index != NULL, FALSE);
+
/* First, look for a literal label match */
for (i = 0; priv->page_labels && i < priv->n_pages; i ++) {
if (priv->page_labels[i] != NULL &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]