C++ (Cpp) g_return_if_fail Examples

C++ (Cpp) g_return_if_fail - 30 examples found. These are the top rated real world C++ (Cpp) examples of g_return_if_fail extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
void
gimp_undo_create_preview (GimpUndo    *undo,
                          GimpContext *context,
                          gboolean     create_now)
{
    g_return_if_fail (GIMP_IS_UNDO (undo));
    g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));

    if (undo->preview || undo->preview_idle_id)
        return;

    if (create_now)
    {
        gimp_undo_create_preview_private (undo, context);
    }
    else
    {
        GimpUndoIdle *idle = g_slice_new0 (GimpUndoIdle);

        idle->undo = undo;

        if (context)
            idle->context = g_object_ref (context);

        undo->preview_idle_id =
            g_idle_add_full (GIMP_VIEWABLE_PRIORITY_IDLE,
                             gimp_undo_create_preview_idle, idle,
                             (GDestroyNotify) gimp_undo_idle_free);
    }
}
Example #2
0
/**
 * g_hash_table_insert:
 * @hash_table: a #GHashTable.
 * @key: a key to insert.
 * @value: the value to associate with the key.
 *
 * Inserts a new key and value into a #GHashTable.
 *
 * If the key already exists in the #GHashTable its current value is replaced
 * with the new value. If you supplied a @value_destroy_func when creating the
 * #GHashTable, the old value is freed using that function. If you supplied
 * a @key_destroy_func when creating the #GHashTable, the passed key is freed
 * using that function.
 **/
void
g_hash_table_insert (GHashTable *hash_table,
                     gpointer	 key,
                     gpointer	 value)
{
    GHashNode **node;

    g_return_if_fail (hash_table != NULL);
    g_return_if_fail (hash_table->ref_count > 0);

    node = g_hash_table_lookup_node (hash_table, key);

    if (*node)
    {
        /* do not reset node->key in this place, keeping
         * the old key is the intended behaviour.
         * g_hash_table_replace() can be used instead.
         */

        /* free the passed key */
        if (hash_table->key_destroy_func)
            hash_table->key_destroy_func (key);

        if (hash_table->value_destroy_func)
            hash_table->value_destroy_func ((*node)->value);

        (*node)->value = value;
    }
    else
    {
        *node = g_hash_node_new (key, value);
        hash_table->nnodes++;
        G_HASH_TABLE_RESIZE (hash_table);
    }
}
Example #3
0
static void
add_timezone_to_cal_cb (icalparameter *param,
                        gpointer data)
{
    struct ForeachTzidData *ftd = data;
    icaltimezone *tz = NULL;
    const gchar *tzid;

    g_return_if_fail (ftd != NULL);
    g_return_if_fail (ftd->from_client != NULL);
    g_return_if_fail (ftd->to_client != NULL);

    if (!ftd->success)
        return;

    tzid = icalparameter_get_tzid (param);
    if (!tzid || !*tzid)
        return;

    if (g_cancellable_set_error_if_cancelled (ftd->cancellable, ftd->error)) {
        ftd->success = FALSE;
        return;
    }

    ftd->success = e_cal_client_get_timezone_sync (ftd->from_client, tzid, &tz, ftd->cancellable, ftd->error);
    if (ftd->success && tz != NULL)
        ftd->success = e_cal_client_add_timezone_sync (ftd->to_client, tz, ftd->cancellable, ftd->error);
}
/**
 * gst_event_parse_qos_full:
 * @event: The event to query
 * @type: (out): A pointer to store the QoS type in
 * @proportion: (out): A pointer to store the proportion in
 * @diff: (out): A pointer to store the diff in
 * @timestamp: (out): A pointer to store the timestamp in
 *
 * Get the type, proportion, diff and timestamp in the qos event. See
 * gst_event_new_qos_full() for more information about the different QoS values.
 *
 * Since: 0.10.33
 */
void
gst_event_parse_qos_full (GstEvent * event, GstQOSType * type,
                          gdouble * proportion, GstClockTimeDiff * diff, GstClockTime * timestamp)
{
    const GstStructure *structure;

    g_return_if_fail (GST_IS_EVENT (event));
    g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_QOS);

    structure = event->structure;
    if (type)
        *type =
            g_value_get_enum (gst_structure_id_get_value (structure,
                              GST_QUARK (TYPE)));
    if (proportion)
        *proportion =
            g_value_get_double (gst_structure_id_get_value (structure,
                                GST_QUARK (PROPORTION)));
    if (diff)
        *diff =
            g_value_get_int64 (gst_structure_id_get_value (structure,
                               GST_QUARK (DIFF)));
    if (timestamp)
        *timestamp =
            g_value_get_uint64 (gst_structure_id_get_value (structure,
                                GST_QUARK (TIMESTAMP)));
}
/**
 * gst_event_parse_buffer_size:
 * @event: The event to query
 * @format: (out): A pointer to store the format in
 * @minsize: (out): A pointer to store the minsize in
 * @maxsize: (out): A pointer to store the maxsize in
 * @async: (out): A pointer to store the async-flag in
 *
 * Get the format, minsize, maxsize and async-flag in the buffersize event.
 */
void
gst_event_parse_buffer_size (GstEvent * event, GstFormat * format,
                             gint64 * minsize, gint64 * maxsize, gboolean * async)
{
    const GstStructure *structure;

    g_return_if_fail (GST_IS_EVENT (event));
    g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_BUFFERSIZE);

    structure = event->structure;
    if (format)
        *format =
            g_value_get_enum (gst_structure_id_get_value (structure,
                              GST_QUARK (FORMAT)));
    if (minsize)
        *minsize =
            g_value_get_int64 (gst_structure_id_get_value (structure,
                               GST_QUARK (MINSIZE)));
    if (maxsize)
        *maxsize =
            g_value_get_int64 (gst_structure_id_get_value (structure,
                               GST_QUARK (MAXSIZE)));
    if (async)
        *async =
            g_value_get_boolean (gst_structure_id_get_value (structure,
                                 GST_QUARK (ASYNC)));
}
Example #6
0
/**
 * g_hash_table_replace:
 * @hash_table: a #GHashTable.
 * @key: a key to insert.
 * @value: the value to associate with the key.
 *
 * Inserts a new key and value into a #GHashTable similar to
 * g_hash_table_insert(). The difference is that if the key already exists
 * in the #GHashTable, it gets replaced by the new key. If you supplied a
 * @value_destroy_func when creating the #GHashTable, the old value is freed
 * using that function. If you supplied a @key_destroy_func when creating the
 * #GHashTable, the old key is freed using that function.
 **/
void
g_hash_table_replace (GHashTable *hash_table,
                      gpointer	  key,
                      gpointer	  value)
{
    GHashNode **node;

    g_return_if_fail (hash_table != NULL);
    g_return_if_fail (hash_table->ref_count > 0);

    node = g_hash_table_lookup_node (hash_table, key);

    if (*node)
    {
        if (hash_table->key_destroy_func)
            hash_table->key_destroy_func ((*node)->key);

        if (hash_table->value_destroy_func)
            hash_table->value_destroy_func ((*node)->value);

        (*node)->key   = key;
        (*node)->value = value;
    }
    else
    {
        *node = g_hash_node_new (key, value);
        hash_table->nnodes++;
        G_HASH_TABLE_RESIZE (hash_table);
    }
}