SFML community forums
Help => General => Topic started by: prchakal on September 14, 2012, 05:14:02 pm
-
Hi,
I made a project that use V8 integration with SFML, but my problem is with custom class/objects that i want that V8 can see.
I created a class "Character" like the same of others "sf_v8" classes. But my application open and close,and the default error "Segment fault".
I can use my project with sf::Sprite class, it is working perfect. But now i want custom classes.
Can anyone help me?
You can see where i stop here:
https://github.com/prsolucoes/sfml-cmake (https://github.com/prsolucoes/sfml-cmake)
Thanks.
-
Make use of your debugger, manual debug checks and the calltrace to find out what goes wrong (that's the not so nice part about programming ;) ).
-
I like debug - step by step :)
I like know whats happen and have full control.
I will search for it, but if you have a light, i will be grateful :)
I think that it is simple and i forgot something, because i copy a sample class in "sf_v8".
Thanks.
-
One thing i discover, that the errori got here:
v8::Handle<v8::Object> Result = Character::POT->NewInstance();
I have commited a working version with custom class commented and working with a simple sprite, while i discover how exchange c++ classes to v8.
---------------
UPDATED:
More specific here:
Character::POT->NewInstance();
---------------
UPDATED - ANOTHER CLUE:
GDB ERROR FROM COMMAND-LINE
Starting program: /Users/paulo/Pessoal/workspaces/qt/sfml-cmake/build/sfml-project.app/Contents/MacOS/sfml-project
Reading symbols for shared libraries .++++++++++.............................................................................................. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x000000010012ec25 in v8::internal::Execution::InstantiateObject ()
--------------------
UPDATED - FULL DETAILED
Now i know where is the problem, but dont know how to solve it :(
Reading symbols for shared libraries . done
Breakpoint 1, main () at /Users/paulo/Pessoal/workspaces/qt/sfml-cmake/main.cpp:82
82 v8::Handle<v8::Object> Result = JSCharacter::POT->NewInstance();
(gdb) step
v8::Handle<v8::ObjectTemplate>::operator-> (this=0x10051bb88) at v8.h:216
216 inline T* operator->() const { return val_; }
(gdb) step
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x000000010012ec25 in v8::internal::Execution::InstantiateObject ()
It is acessing a NULL value but, why?
If we "print" the property "val_", we have a NULL object:
(gdb) print val_
$1 = ('v8::ObjectTemplate' *) 0x0
-
PROBEM SOLVED!!!! URRRULLLLLL!!!!
GDB IS THE BEST!!!!!
I need initialize the null attribute "POT":
JSCharacter::InitPOT(JSCharacter::POT);
v8::Handle<v8::Object> Result = JSCharacter::POT->NewInstance();
Ty.
-
PROBEM SOLVED!!!! URRRULLLLLL!!!!
GDB IS THE BEST!!!!!
Glad you discovered that!
The debugger is one of the most important tools for developers and if used right, many of the questions regarding some errors could get fix by the asking person itself, but granted it needs a bit experience to really make use of it. ;)