Denis Oliver Kropp wrote:
> Phil Endecott schrieb:
>> I am finding the ++dfb library to be an effective way of accessing 
>> directfb from C++, leading to nice simple code.  But I have encountered 
>> some odd crashes.  A fairly minimal example is shown below.
>> 
>> The key point is that I pass *by value* an IDirectFB from the main 
>> program to the load_pic function.  Similar things happen when I pass 
>> other types by value.  But if I change to passing by reference it 
>> works.  I fear that the "main" DirectFB is being destroyed when the 
>> copy in the function is destructed.

>
> I also encountered a ref counting problem in certain situations.
>
>> So, can someone else try this example and see if it also fails for 
>> them?  Do you agree that this ought to work?  Can anyone suggest a 
>> debugging strategy?
>
> We need to do stack traces of each Create/AddRef/Release and find out
> which operators or constructors are to be implemented or maybe some
> are superfluous?

I have compiled 0.9.25 with debugging enabled.  I can't try a more 
recent version because ++dfb doesn't seem to have a 1.0 release 
candidate.  In CVS there seems to be debugging in AddRef and Release, 
but this isn't present in 0.9.25.  Maybe I will try to add that debugging.

Anyway, with the debugging that I do have it's clear that the DFB core 
is being shut down much earlier than it should be, presumably when the 
function returns.  An extract of the debug output follows, starting 
where the JPEG image is loaded.

(*) Direct/Interface: Loaded 'JPEG' implementation of 'IDirectFBImageProvider'.
(-) [Main Thread       0.396] (28999) Core/Layers:       
dfb_layer_get_active_conte
xt (VIA CLE266 Graphics)
(-) [Main Thread       0.396] (28999) Core/Surface:      
dfb_surface_create( core 0
x804e878, size 1350x900, format RGB16 )
(-) [Main Thread       0.396] (28999) Fusion/Object:     == Surface 
Pool ==
(-) [Main Thread       0.396] (28999) Fusion/Object:       -> added 0x80b5bd0
(-) [Main Thread       0.396] (28999) Core/Surface:      
dfb_surface_init( 0x80b5bd
0, 1350x900, RGB16, 0x00000000, (nil) )
(-) [Main Thread       0.396] (28999) Core/Surface:      
dfb_surface_allocate_buffe
r( 0x80b5bd0, 1, RGB16 )
(-) [Main Thread       0.396] (28999) IDirectFBSurface:  
IDirectFBSurface_Construct
( 0x80b5d40 )
(-) [Main Thread       0.396] (28999) IDirectFBSurface:  
IDirectFBSurface_GetPixelF
ormat( 0x80b5d40 )
(-) [Main Thread       0.396] (28999) IDirectFBSurface:  
IDirectFBSurface_GetSize(
0x80b5d40 )
(-) [Main Thread       0.396] (28999) IDirectFBSurface:  
IDirectFBSurface_Lock( 0x8
0b5d40 )
(-) [Main Thread       0.396] (28999) Core/Surface:      
dfb_surface_soft_lock( 0x8
0b5bd0, w, back )
(-) [Main Thread       0.396] (28999) Core/Surface:      
dfb_surface_software_lock(
  0x80b5bd0, w, back )
(-) [Main Thread       0.396] (28999) Core/Surface:        -> auto 
system, counter:
  1
(-) [Main Thread       0.396] (28999) Core/Surface:        -> 
0xb1a72008 [2700]
(-) [Main Thread       0.929] (28999) IDirectFBSurface:  
IDirectFBSurface_Unlock( 0
x80b5d40 )
(-) [Main Thread       0.929] (28999) Core/Surface:      
dfb_surface_unlock( 0x80b5
bd0, back )
(-) [Main Thread       0.929] (28999) Core/Surface:        -> 
system/video count: 1
/0 before
(-) [Main Thread       0.929] (28999) Core/Surface:        -> 
system/video count: 0
/0 after
(-) [Main Thread       0.930] (28999) Fusion/Object:     == Layer 
Context Pool ==
(-) [Main Thread       0.930] (28999) Fusion/Object:       -> dead 
object 0x8064af0
  [1]
(-) [Main Thread       0.930] (28999) Fusion/Object:       -> calling 
destructor...
(-) [Main Thread       0.930] (28999) Core/Layers:       destroying 
context 0x8064a
f0 (VIA CLE266 Graphics, inactive)
(-) [Main Thread       0.930] (28999) Core/Layers:       
dfb_layer_remove_context (
VIA CLE266 Graphics, 0x8064af0)
(-) [Main Thread       0.930] (28999) Core/Input:        
dfb_input_detach_global( 0
x8070e48, 0x8064e68 )
(-) [Main Thread       0.930] (28999) Core/Input:        
dfb_input_detach_global( 0
x8070c20, 0x8064e38 )
(-) [Main Thread       0.930] (28999) Core/Input:        
dfb_input_detach_global( 0
x8064910, 0x809fea0 )
(-) [Main Thread       0.930] (28999) Core/Input:        
dfb_input_detach_global( 0
x8076a40, 0x809fe70 )
(-) [Main Thread       0.930] (28999) Core/Input:        
dfb_input_detach_global( 0
x804b650, 0x80748e8 )
(-) [Main Thread       0.930] (28999) Fusion/Object:       -> 
destructor done.
(-) [Main Thread       0.930] (28999) DirectFB/Core:     dfb_core_destroy...
(-) [Main Thread       0.930] (28999) Direct/Signals:    Removing 
handler 0xb7e3c3b
0 for signal -1 with context 0x804e878...
(-) [Main Thread       0.930] (28999) DirectFB/Core:     Shutting down...


If anyone else has tried to run the example code from my previous 
message I would be interested to know whether or not it has worked for you.

Phil.





_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to