• Create Account

### #Actualzerochen

Posted 11 October 2012 - 05:28 PM

hi,

i have following base structure
Script:
class A
{
};

class B
{
void init()
{
create("A");
};
};


pseudo c++:
asIScriptObject* create(string s)
{
int id = getClassId(s);
return reinterpret_cast<asIScriptObject*>(engine->CreateScriptObject(id));
}


so now to my problem.

i create class B and than i call the function init() from B that creates a new object from A
something like this:

pseudo call stack:
objB = create("B")
objB.callMethod("init")
that calls
objA = create("A")


after that the ref count of objB is 1 (as expected)
the ref count of objA is 2 (have to be 1)

have i an error in my logic?

i tracked this down to:
as_scriptobject.cpp line 122
that line doesnt dec the ref counter of objA but it does it for objB.

is that because to call a script function there has to be an active context?

is this a bug or have i call the release func myself?

thx for help
zerochen

### #2zerochen

Posted 11 October 2012 - 05:27 PM

hi,

i have following base structure
Script:
class A
{
};

class B
{
void init()
{
create("A");
};
};


pseudo c++:
asIScriptObject* create(string s)
{
int id = getClassId(s);
return reinterpret_cast<asIScriptObject*>(engine->CreateScriptObject(id));
}


so now to my problem.

i create class B and than i call the function init() from B that creates a new object from A
something like this:

pseudo call stack:
objB = create("B")
objB.callMethod("init")
that calls
objA = create("A")


after that the ref count of objB is 1 (as expected)
the ref count of objA is 2 (have to be 1)

have i an error in my logic?

i tracked this down to:
as_scriptobject.cpp line 122
that line doesnt dec the ref counter of objA but it does it for objB.

is that because to call a script function there have to be an active context?

is this a bug or have i call the release func myself?

thx for help
zerochen

### #1zerochen

Posted 11 October 2012 - 05:08 PM

hi,

i have following base structure
Script:
class A
{
};

class B
{
void init()
{
create("A");
};
};


pseudo c++:
asIScriptObject* create(string s)
{
int id = getClassId(s);
return reinterpret_cast<asIScriptObject*>(engine->CreateScriptObject(id));
}


so now to my problem.

i create class B and than i call the function init() from B that creates a new object from A
something like this:

pseudo call structure:
objB = create("B")
objB.callMethod("init")
that calls
objA = create("A")


after that the ref count of objB is 1 (as expected)
the ref count of objA is 2 (have to be 1)

have i an error in my logic?

i tracked this down to:
as_scriptobject.cpp line 122
that line doesnt dec the ref counter of objA but it does it for objB.

is that because to call a script function there have to be an active context?

is this a bug or have i call the release func myself?

thx for help
zerochen

PARTNERS