[Gambas-user] Segfault when overriding Variant[]

tobi tobiasboege01 at ...1601...
Tue May 1 10:47:13 CEST 2012


On Tue, 01 May 2012, tobi wrote:
> Hi,
> 
> I promptly get a segfault when I try to create an instance of my extended Variant[]:
> 
> .src/Variant[].class
> --8<---------
> ' Gambas class file
> 
> Export
> 
> Public Sub _compare(hV As Variant[]) As Integer
>   Return 0
> End
> --8<---------
> 
> .src/MMain.module
> --8<---------
> ' Gambas module file
> 
> Public Sub Main()
>   Dim hV As New Variant[]
> End
> --8<---------
> 
> I hope that it's possible to override native classes?
> 
> Regards,
> Tobi

Oh, I should look first and then post...
Segfault comes from
gbx_class.c:1358:
	array_type->array_class = class;
but before that in the same function:
	CLASS *array_type = (CLASS *)class->array_type;
and look at:
(gdb) print class->array_type
$2 = 12

which is GB_T_VARIANT, as supposed to be since I exported a Variant[].
I think creating that as a pointer is a bug. (Creating arrays of native datatypes not expected?)

The article about Gambas object model says that gb.qt Application extends gb Application so, I am
allowed to extend native classes!

Regards,
Tobi




More information about the User mailing list