> Viktor Szakáts wrote:
>> Anyway, it doesn't work here. First I have to copy in lots of .dlls, then I 
>> get this:
> 
> Lots? I last release only two of them: libcairo-2.dll and libpng12-0.dll, if 
> you do not need png support (by default png is enabled), libcairo-2.dll can 
> be recompiled without png support.

Depends on the distro. One of my distros 
use above two .dlls. The first problem is 
that they forgot to supply libpng12-0.dll.

When I copy it in from another distro and 
change the name (coz it's naturally different 
in each distro), I got a GPF.

So I tried the other distro (full GTK bin 
pkg) which needed all the .dlls listed in 
the GPF dump, but it crashed also.

BTW, I fear that it's practically impossible 
(means: takes a too huge amount of work) to 
build a static lib of cairo due to its 
numerous dependencies.

>> ---
>> Application Internal Error - 
>> F:\work\harbour\harbour\contrib\hbcairo\tests\fancytxt.exe
>> Terminated at: 2009.11.30 22:44:06
>> Unrecoverable error 6005: Exception error: Called from 
>> CAIRO_SELECT_FONT_FACE(0)
>> Called from DRAW(41) in fancytxt.prg
>> Called from MAIN(12) in fancytxt.prg
> 
> Yes, it's sensitive place. For example, I get a GPF if I leave an open .pdf 
> file in Acrobat Reader and I try to render to this .pdf file. Perhaps we must 
> add check if cairo created a valid surface using cairo_surface_status() and 
> add a similar protection and check for return value in other places.

I've seen a few places where hb_parc() is passed 
to cairo directly. This is only good if cairo accepts 
NULL. If not, use hb_parcx(), or go to error branch 
if ! HB_ISCHAR().

> I'll try to do it in the future. This is also related to a question:
> 
>> 3)What is correct way to code:
>>   pCairo = hb_cairo_par( 1 ); // generate RTE if parameter is wrong
>>   if( pData )
>>      cairo_something( pCairo );
>> or this is also ok?:
>>    cairo_something( hb_cairo_par( 1 ) ); 

The first one is right. You should always 
check for at least NULL, as users may just 
pass other types, or non-cairo handles to 
the functions.

I use this in hbcurl:

---
HB_FUNC( CURL_WHATEVER )
{
   if( PHB_CURL_is( 1 ) )
   {
      PHB_CURL hb_curl = PHB_CURL_par( 1 );

      if( hb_curl )
         (code)
      else
         hb_retc_null();
   }
   else
      hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, 
HB_ERR_ARGS_BASEPARAMS );
}
---

First I check if it's a CURL handle. If not 
an RTE is passed because it's most probably 
programming error. If it's CURL handle, I 
retrieve it, and if it's NULL I just return 
error value silently because in this case 
CURL initialization failed.

CURL example is a little different because 
it uses container object, not direct libcurl 
handle.

In your case you can decide if RTE or error 
return value is more convenient.

Brgds,
Viktor

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to