~noskcaj/ubuntu/trusty/cogl/1.16.2

« back to all changes in this revision

Viewing changes to cogl/cogl-error.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha, Jeremy Bicha, Rico Tzschichholz
  • Date: 2013-02-26 16:43:25 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130226164325-t4z9rylpa20v0p6q
Tags: 1.13.4-0ubuntu1
[ Jeremy Bicha ]
* New upstream release
  - soname bump
* debian/control.in:
  - Bump minimum glib to 2.32
  - Drop obsolete breaks/replaces
  - Bump libclutter-1.0-dev breaks for soname transition
* debian/libcogl-dev.install:
  - Add some missing files

[ Rico Tzschichholz ]
* debian/control.in:
  - Build-depend on libxrandr-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * An object oriented GL/GLES Abstraction/Utility Layer
 
5
 *
 
6
 * Copyright (C) 2011 Intel Corporation.
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library; if not, write to the
 
20
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
21
 * Boston, MA 02111-1307, USA.
 
22
 *
 
23
 * Authors:
 
24
 *   Robert Bragg <robert@linux.intel.com>
 
25
 */
 
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include "config.h"
 
29
#endif
 
30
 
 
31
#include "cogl-types.h"
 
32
#include "cogl-util.h"
 
33
#include "cogl-error-private.h"
 
34
 
 
35
#include <glib.h>
 
36
 
 
37
void
 
38
cogl_error_free (CoglError *error)
 
39
{
 
40
  g_error_free ((GError *)error);
 
41
}
 
42
 
 
43
CoglError *
 
44
cogl_error_copy (CoglError *error)
 
45
{
 
46
  return (CoglError *)g_error_copy ((GError *)error);
 
47
}
 
48
 
 
49
CoglBool
 
50
cogl_error_matches (CoglError *error,
 
51
                    uint32_t domain,
 
52
                    int code)
 
53
{
 
54
  return g_error_matches ((GError *)error, domain, code);
 
55
}
 
56
 
 
57
#define ERROR_OVERWRITTEN_WARNING \
 
58
  "CoglError set over the top of a previous CoglError or " \
 
59
  "uninitialized memory.\nThis indicates a bug in someone's " \
 
60
  "code. You must ensure an error is NULL before it's set.\n" \
 
61
  "The overwriting error message was: %s"
 
62
 
 
63
void
 
64
_cogl_set_error (CoglError **error,
 
65
                 uint32_t domain,
 
66
                 int code,
 
67
                 const char *format,
 
68
                 ...)
 
69
{
 
70
  GError *new;
 
71
 
 
72
  va_list args;
 
73
 
 
74
  va_start (args, format);
 
75
 
 
76
  if (error == NULL)
 
77
    {
 
78
      g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
 
79
      va_end (args);
 
80
      return;
 
81
    }
 
82
 
 
83
  new = g_error_new_valist (domain, code, format, args);
 
84
  va_end (args);
 
85
 
 
86
  if (*error == NULL)
 
87
    *error = (CoglError *)new;
 
88
  else
 
89
    g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
 
90
}
 
91
 
 
92
void
 
93
_cogl_set_error_literal (CoglError **error,
 
94
                         uint32_t domain,
 
95
                         int code,
 
96
                         const char *message)
 
97
{
 
98
  _cogl_set_error (error, domain, code, "%s", message);
 
99
}
 
100
 
 
101
void
 
102
_cogl_propagate_error (CoglError **dest,
 
103
                       CoglError *src)
 
104
{
 
105
  _COGL_RETURN_IF_FAIL (src != NULL);
 
106
 
 
107
  if (dest == NULL)
 
108
    cogl_error_free (src);
 
109
  else if (*dest)
 
110
    g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
 
111
  else
 
112
    *dest = src;
 
113
}
 
114
 
 
115
/* This function is only used from the gdk-pixbuf image backend so it
 
116
 * should only be called if we are using the system GLib. It would be
 
117
 * difficult to get this to work without the system glib because we
 
118
 * would need to somehow call the same g_error_free function that
 
119
 * gdk-pixbuf is using */
 
120
#ifdef COGL_HAS_GLIB_SUPPORT
 
121
void
 
122
_cogl_propagate_gerror (CoglError **dest,
 
123
                        GError *src)
 
124
{
 
125
  _cogl_propagate_error (dest, (CoglError *) src);
 
126
}
 
127
#endif /* COGL_HAS_GLIB_SUPPORT */