IRC Log Viewer » #firebreath » 2012-09-05

IRC Nick Time (GMT-7) Message
Guest37764 07:09 Hello taxilian "you're trying to fire an event; you using the firebreath event macro? then how are you calling it?"
II put FB_JSAPI_EVENT(name, 2, (const int&, const std::string&)); in my object header
IIn public scope
And I have FireEvent function scope problem or Plugin crash when it compile (extending my object with JSAPIAUto) and call fire_name(...)
In conclusion, my project compile FB_JSAPI_EVENT when i extend my object with JSAPIAuto
But when I try to call a JS function, that create one instance of my object that calls fire_name, then plugin crash
reichi 08:09 paste your compiler error on pastebin or similar
"i have an compiler error" is no help at all
it's like
"my car doesn't work, cann you tell me what's broken?"
if the compiler already fails your code has obvious errors
Guest37764 08:09 error: ‘FireEvent’ is not declared at this scope
reichi 08:09 your class hierarchy is broken
or your code
Guest37764 08:09 When I extend with JSAPIAuto
all compiles
reichi 08:09 yes
you HAVE to
if you want events
Guest37764 08:09 Ok
But, when I call fire_test, fire_name or whatever
reichi 08:09 (not specifically Auto, but JSAPIAnything)
Guest37764 08:09 Thanks ;)
When fire_XXX
plugin crash
reichi 08:09 find out why
or give us code
I'm sorry but my farseer glass thingy recently broke apart
;)
many times it's already enough to just see the crash in gdb or any other debugger
for a clue of what breaks
(in gdb after a "bt full" after it segfaulted)
Guest37764 08:09 I try
reichi 08:09 alternative
if your code is not confidential
paste it somewhere
maybe it's obivous why it breaks
oh, don't raise events in the constructor ;)
though i never tried, I'm pretty certain it will crash
the earliest possible point of doing things like that is right when onPluginReady is called in your FB::PluginCore-derived class
Guest37764 08:09 Yes, a few days ago I talk with u, And this was one of my problems :D
We solve it
reichi 08:09 i don't know if it's the same for you event-raise ;)
Guest37764 08:09 But now, my "main problem" (the events) persists
I try execute gdb
but i need reboot chrome
reichi 08:09 oh, that will be painful
but best of luck ;)
Guest37764 08:09 in 3 minutes, I come back with some "trace" xD
I hope
thx
reichi 08:09 haha
you won't
i'm sure :/
beezboy 08:09 I come back..........again!
This is the trace of fire_XXX event crash in my own object
http://pastebin.com/D9jPuzmV
Object that extends FB::JSAPIAuto
reichi 08:09 nullpointer
beezboy 08:09 Wow, u are a machine
reichi 08:09 no
boost::throw_exception<boost::bad_weak_ptr>(boost::bad_weak_ptr const&)
why could a pointer be bad?
usually becaues it's a nullpointer
beezboy 08:09 How is possible, I put the sme libries, extend objects... and I cant execute the FB_JSAPI_EVENT
Now I havent compiler erros
reichi 08:09 you are doing something wrong
where do you call fire_SomeEvent?
i assume you fire too soon
beezboy 08:09 I call in object method
I assume that JSAPI is Ready
Because this object is created from when user calls specific JSAPI function
I suspect... that my object is not "correctly connected" with JSAPI or something like that
But this reason I cant trigger events
directly
beezboy 09:09 COMPLET skeleton of my problem: http://pastebin.com/FmuVSBQ5
reichi 09:09 oh
a singleton
how is that supposed to work?
http://www.firebreath.org/display/documentation/Best+Practices
"Dealing with JSAPI objects"
first thing to read
the browser takes ownership of ANY object exposed to it
you have no control over pointers if you're not careful ;)
(and know what you're doing)
beezboy 09:09 shit I try to delete it
but... events work?
How I can create a Object instance?
reichi 09:09 first add a typedef
typedef boost::shared_ptr<MyJSAPIAutoClass> MyJSAPIAutoClassPtr;
at the end of your header
beezboy 09:09 ok
is ready
and how can I call it?
from original PluginAPI
reichi 09:09 MyJSAPIAutoClassPtr instance = boost::make_shared<MyJSAPIAutoClass>()
beezboy 09:09 I try it...
beezboy 10:09 Well the null pointers problem is solved
The plugin dont crash now, when I call fire_XX (js events) with my own object)
But, nothing appers in browser
An I have a listener
taxilian 10:09 you need to use the same JSAPI object that you attached the handler to
reichi: if he creates a new instance he isn't doing that
boost::dynamic_pointer_cast<MyJSAPIAutoClass>(getRootJSAPI())->fire_xx()
getRootJSAPI reutrns the JSAPIPtr for the root JSAPI instance for your plugin
then you cast it to the type you need
FB::ptr_cast<MyJSAPIAutoClass> works too; it's a shortcut for dyanmic_pointer_cast
beezboy 10:09 I put this in my object, for call event declareted in PLuginAPI?
taxilian 10:09 yes
beezboy 10:09 Ok, I try, this seems more logic
compiler error: getRootJSAPI() is not at this scope
taxilian 10:09 I guess I was making an assumption that the object you were talking about was your plugin object
beezboy 10:09 Sorry for this
I have a new Object
Created by me
taxilian 10:09 then you will have to give the object a reference to your JSAPI object
be very careful with that; your object *must* get cleaned up or release the reference before the plugin object finishes shutting down
beezboy 10:09 Ok this is not a problem
Few days ago I try to get this pointer
But I have only access to ->Invoke ant etc methods
I need trigger an event
taxilian 10:09 okay
homework assignment
go learn how boost::shared_ptr works
then learn about boost::dynamic_pointer_cast
and dynamic casting in c++ in general
beezboy 11:09 Ok
Its only a suggest
taxilian 11:09 ?
beezboy 11:09 I think that documentation is good for most of people
taxilian 11:09 if you understand those things, then you will understand how to get from the JSAPIPtr that you have to the MyJSAPIAutoClassPtr that you want
beezboy 11:09 But more examples in this direction, I think that help people that not knows weel c++ and boost
taxilian 11:09 feel free to contribute them
=]
beezboy 11:09 Yes,
When this work, correctly
taxilian 11:09 I dont' do the documentation; I spend my time fixing bugs and adding features as needed =]
beezboy 11:09 I send you this stupid question
taxilian 11:09 I figure that if users find it useful, they can add the documentation and I'll make sure it stays accurate
beezboy 11:09 for documentation or to do what you want :D
Yes, I am with u
taxilian 11:09 firebreath.org is a wiki
anyone can edit it
beezboy 11:09 Ok, my know in this topics have a "limit"
But I try contribute with this questions
I appreciate very much your help
reichi 11:09 not knowing c++ well is not a good starting point for a firebreath project
boost helps a lot
with typical problems
beezboy 11:09 I know c++ at same time that firebreath
reichi 11:09 that's an incredibly hard task
imo
beezboy 11:09 Really this project its "simply", because i need integrate a 3rdParty lib
But this concepts are very new for me
reichi 11:09 npapi is never simple
beezboy 11:09 I learned some C at University, but its insufficient
reichi 11:09 as you just discovered ;)
beezboy 11:09 Yes
reichi 11:09 anything you learn at university is insufficient ;)
beezboy 11:09 A very wonderful world
reichi 11:09 it's only the beginning ;)
beezboy 11:09 I buy a "Professional C++" book
(2011)
I think that is a good book
But most important is practise
Well guys, I do taxilian homework and study the tips that you talked me
Very help full
helpful* for me, thanks...
I hope contribute with something in future ;)
reichi 11:09 well, i may have not been specific enough on exactly you'll have to do
recreating instance will cause what you described
and as taxillian said you totally have to get rid of your instance on plugin shutdown
which StaticDeinitialize is usually a good point to use for
taxilian 11:09 reichi: no, that would be the module shutdown. it needs to go away before *plugin instance* shutdown
so the shutdown() function on the plugin is a reasonable place
really you just don't want to hold a shared_ptr reference to the plugin or the JSAPI object after the instance shuts down
reichi 11:09 oh, right
after all, that's why i always say "if you want to be sure, ask taxillian" :p