SoupURI: add SOUP_URI_IS_VALID() and use it for basic precondition checks
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 3 Feb 2012 14:13:32 +0000 (14:13 +0000)
committerDan Winship <danw@gnome.org>
Mon, 6 Feb 2012 22:12:26 +0000 (17:12 -0500)
commit675979d4aa6a72d8415294f989aeb20a6eae2ab6
tree4510811e051e524d4c302048e25b8a7069b6e05d
parent9a7fee1ef398877d0950ab66837ecb25fe1f960c
SoupURI: add SOUP_URI_IS_VALID() and use it for basic precondition checks

In this patch, field setters don't have precondition checks for the
validity of the URI object itself, only a non-NULL check, to avoid
breaking existing code if it calls soup_uri_new (NULL) and then sets
fields in an unexpected order:

    uri = soup_uri_new (NULL);                    /* uri is invalid */
    soup_uri_set_host (uri, "www.google.com");
    soup_uri_set_query (uri, "q=badgers");
    soup_uri_set_scheme (uri, "http");            /* still invalid... */
    soup_uri_set_path (uri, "/search");           /* finally valid */

Also annotate nullable setter parameters as (allow-none), to justify
why they don't have a precondition check.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=667637
Bug-NB: NB#294977
libsoup/soup-uri.c
libsoup/soup-uri.h