g_try_new and g_try_new0 + error reporting for g_object_set



hi hi,

is there a reason why we dont have g_try_new and g_try_new0.

Why I am asking? We use g_new a lot in our code. Recently we have added a helper
method to our unit-tests that goes over gobject properties of a given instance
and does read/write checks.
This triggered a 'problem'. For one class there is a property denoting the size
of a data-structure (number of slots). One can write to this property and then
the datastructure will adapt its size.
On one hand we do not want to limit the size more than neccesary, so the number
of entries is a g_ulong. The unit-testing code now tried to set the property to
the largest ulong and this caused it to abort, as g_new0 wasn't be able to
allocate that much. Now here would would rather like to notifiy the user that we
were not be able to perform that operation, than just aborting.
Therefor the need for g_try_new0.

The second thing is how does one report that a g_object_set failed? All I can
currently think of is an error-property in the object, which the caller can
connect a notify handler on and retrieve the GError object in case of a problem.

Sorry if this is a bit offtopic, its more a best-practise question...

Stefan
-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -
begin:vcard
fn:Stefan Kost
n:Kost;Stefan
org:HTWK Leipzig;FB. IMN
adr:;;Postfach 301166;Leipzig;;04251;Germany
email;internet:kost imn htwk-leipzig de
title:Dipl. Informatiker
tel;work:+49341 30766440
tel;home:+49341 2253538
tel;cell:+49178 3183742
x-mozilla-html:FALSE
url:http://www.imn.htwk-leipzig.de/~kost/about.html
version:2.1
end:vcard



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