IRC Log Viewer » #firebreath » 2011-12-08

IRC Nick Time (GMT-7) Message
taxilian 08:12 FireBreathBot: tell shenberg all instances of the plugin will always be on the same thread in a given browser; multiple browsers will each have their own process.
FireBreathBot 08:12 taxilian: I'll pass that on when shenberg is around.
taxilian 09:12 linearray: so this code works to do a modal dialog?
linearray 11:12 yes
I don't really know what it does
but it works
taxilian 11:12 lol
I know what it does; I'm fairly impressed that it works
on all browsers? no locking up of the browser or anything?
no "this plugin isn't responding"?
linearray 11:12 tried chrome and safari, not locking up
taxilian 11:12 awesome
so what is happening is that you are using the main event loop of the process
the reason it normally thinks that your plugin has locked up is that it doesn't return from the call
this way you let it return, but you schedule something to run whenever convenient; because it runs as a normal thing on the NSThread event loop the event loop can continue normally while you're in the dialog and it didn't prevent any plugin calls from continuing
like I said; very clever
linearray 11:12 I guess this will not work on < 10.6
taxilian 11:12 hmm. that's a point; < 10.6 I don't think the closure you're using works
however, this gives me an idea that I can probably use to make it work anyway
linearray 11:12 if not even the vendor supports 10.5 anymore, I guess neither will I
taxilian 11:12 hehe. well, unfortunately I have to support 10.5 still
ppc even :-/
linearray 11:12 in fact, if you see 10.5 in the wild it's probably better to just root it
taxilian 11:12 yeah
just thought of something
is your code in a state that you could do a fairly quick test for me?
(you were able to reliably repro that crash, right?)
linearray 11:12 22:34 < gwynne> linearray: The naive fix would be to do the body of the method within a [self performSelectorOnMainThread:...waitUntilDone:YES]
that probably works on 10.5 as well
not really
but just send me the code, I will try to do it later
taxilian 11:12 that's basically what I'm thinking
why is that the naive fix? will it not work?
well, except the waitUntilDone part
that wouldn't work
I can probably get my boss to test it; thanks, though
ssdc 12:12 simple question, but just can't seem to find my answer in the examples and documentation ... but how do I define an optional parameter that can be any object (ie, string, integer, array, hash, etc.)? I thought boost::optional<FB:variant&> made sense, but doesn't compile.
my end goal is to be able to convert the object into a JSON string ...
taxilian 12:12 for parameters to a JSAPIAuto function you either need to do const type& or just type
you can't do a type&
variant will actually work for an optional type by itself, however
you dont' need boost::optional
the variant will return true for .empty() if it's not provided (same as if you give it undefined)
objects like that I recommend using const type&, though; so const variant& would be the most efficient
ssdc: hope that helps
ssdc 12:12 ok ... I'll remove the boost::optional and use const type&. Thanks.
taxilian 12:12 const variant& specifically
type is a placeholder there =]
ssdc 12:12 yup - I got that :)
taxilian 12:12 just checking =]
string is another type that it's best to use const &
ssdc 12:12 so, perhaps this is a longer conversation than it needs to be - but why exactly is it more efficient?
taxilian 12:12 because if you pass it by value it will need to copy the type
so passing a std::string it will actually copy the string when it calls the function
if you pass a const std::string& it will reuse the one that was passed to it
ssdc 12:12 ok - makes sense
taxilian 12:12 if you use a std::string& it will reuse it, but if it isn't the exact correct type it can't coerce it into the right type; this is pointless to allow to a JSAPI method because passing by reference and not const is pointless unless you need the value outside of the function, which we don't because it's a temporary value
you can pass "some string" into a const std::string&, but not into a std::string& for example
ssdc 12:12 cool ...
taxilian 12:12 it's actually good general practice in c++ to const all parameters that don't specifically need to not be const
and then except primitive types use const &
(const & for an int or other primitive type is pointless as well)
in fact, for a primitive type it may be more expensive, since the memory reference may be larger than the value itself =]
ssdc 12:12 good to know ... yeah, I'm trying to pick C++ after a number of years away and a lot of these little nuances especially around memory usage (and especially after coming from C#) takes a little to get back into it
taxilian 12:12 there is a really good book for that, if you're interested
ssdc 12:12 sure
taxilian 12:12
this is where I learned a lot of what I just told you
though some came from trial and error
that link will donate a small percentage to the FB project as well
(I should probably put that one of the FB website)
ssdc 12:12 awesome, thanks for the tip
linearray 12:12 why is coercion possible from const char* to const std::string&?
I don't see why this works
taxilian 12:12 because there is a constructor of std::string that takes const char*
so it can implicitely convert it to a std::string
linearray 12:12 yeah and that gives you a std::string
why does it have to be const std::string&
taxilian 12:12 right; you can coerce it implicitely for either "const std::string&" or "std::string" but not "std::string&"
because if it's const, it won't be changing, so it doesn't have to be a valid object before passing it in
linearray 12:12 ha, ok
taxilian 12:12 it can use an implicitely created temporary object
linearray 12:12 crazy
taxilian 12:12 same thing with any of the functions in firebreath that use const FB::variant&; it can accept any variant-compatible type implicitely
like magic =]
bovilexic 13:12 Gotta question about the BasicMediaPlayer...
taxilian 13:12 heh. okay
it's not really maintained, just FYI
bovilexic 13:12 Yeah. I lifted some code from it to do a plugin that uses OpenGL (Mac). Got it working, but it insists on calling for a redraw every 1/30 second. How do I turn this off?
Tried calling wnd->StopAutoInvalidate(); in the onWindowAttached() method, to no effect...
taxilian 13:12 don't call StartAutoInvalidate
bovilexic 13:12 Got that commented out...also I disabled DrawingModelInvalidatingCoreAnimation. Have no idea why its starting...
taxilian 13:12 well, if you aren't calling StartAutoInvalidate then it won't be calling a redraw; at least, the framework won't. it's possible CA is doing something, but my guess would be that you are using the wrong version or something
bovilexic 13:12 Yeah, could be CA...
"wrong version" of what?
taxilian 13:12 in other words, you recompiled but you aren't using the new version that you build
because you didn't copy it, didn't restart the browser, didn't… whatever
bovilexic 13:12 That might be it. Trying to be careful, but the workflow is a little fragile :-)
I'll make sure everything is cleaned up, etc. and get back if this doesn't fix it...thanks...
taxilian 13:12 good luck
linearray 14:12 ok i just read assign to const reference, involving type coercion, is a special case
like vector<bool> ;)
maybe more useful though.
taxilian 14:12 special case in what way?
linearray 14:12 in that the compiler creates a temporary and frees it when the reference runs out of scope
taxilian 14:12 ahh
so you're saying I was right? =]
linearray 14:12 sure
but i didnt understand why its doing what it does... and the answer is "it's in the standard"
taxilian 14:12 hehe
andrew211 16:12 Hey. How do I find out what version of FB I have installed? I have an old copy here with no version file that exists on the github version. I grep'd the source for 'version' but theres too many references
taxilian 16:12 andrew211: where did you get it originally?
is there a "version" file in the root?
andrew211 16:12 the official FB site
taxilian 16:12 the official FB site doesn't have downloads; you would have had to get it from google code or github
there should be a file "version" in the root unless it's a really old version
andrew211 16:12 it was 6/12 months ago I think; and I don't see a version file unfortunately
taxilian 16:12 that's not a good sign :-P do you have a Factory.cpp?
in your project?
andrew211 16:12 yep
taxilian 16:12 okay, that's good; I'm guessing you're around 1.3, possibly 1.4
andrew211 16:12 haha the bottom of the version history page :)
ok; I just want to upgrade my project so ill work my way up from there fixing breaking changes
taxilian 16:12 when you build is there a "global/" directory in build/projects/your_plugin/gen?
andrew211 16:12 nope
1.3 or 1.4 sounds familiar
taxilian 16:12 you're on 1.3
that's going to be a bit more of a hassle to update, I'm afraid, but it shouldn't be terrible
you should really update more
andrew211 16:12 great thank you
taxilian 16:12 I promise I don't put out major releases without good reason =]
andrew211 16:12 ideally :)
thankfully this plugin is pretty simple, basically just a 'are you installed' plugin
Are you Richard? from
taxilian 16:12 yes
taxilian is my screen name
andrew211 16:12 I worked out one problem I was encountering is because the auto download of the boost libraries isn't working right; its not unpacking a 'libs' folder
taxilian 16:12 that's annoying
might be paritally because you were trying to override your old fb dir instead of providing a new one
don't ever try to do that; just make a new one
andrew211 16:12 yep
but nah, this was a fresh install (to check I wasn't doing something silly)
check out if your interested
fresh download of 1.6 stable, unzipped. then ran prep2008 examples
src/3rdparty/boost has boost, bcp_command,
but no libs folder
taxilian 16:12 weird; wonder why that would happen
I really suggest getting firebreath with git, to be honest; the other usually works, but is much more error prone
andrew211 16:12 line 51 of that pastebin shows an error, maybe due to //libs instead of /libs but who knows
taxilian 16:12 that is really strange, though
maybe so
but it usually works :-/
andrew211 16:12 yeah, Ive played with git a little; really should look into it more
taxilian 16:12 is a great resource for getting started
andrew211 16:12 with the .net guy joining github hopefully windows git dev will be easier !
taxilian 16:12 git extensions is a great git UI; I haven't had any trouble wtih it
for windows
andrew211 16:12 will check it out cheers; I looked it git properly about a year ago and the ui was a bit annoying and kludgy at the time, it may have been tortisegit I used though
taxilian 16:12 yeah, tortoisegit is worthless, IMO
good luck
glad you figured out the boost thing
andrew211 16:12 thanks for the help, appreciate it
taxilian 16:12 yw
andrew211 16:12 one last question; I have revised my folder layout as per your post on google; but how do I copy across the sln files? They were autogenerated too
taxilian 16:12 you don't
andrew211 16:12 or perhaps I should fbgen a new plugin with the same details, then just try overwriting the generated files or something
taxilian 16:12 you never copy, save, or move those
those are created by the prep script
the whole build directory is disposable
andrew211 16:12 ahh
taxilian 16:12 created by cmake
not by fbgen
fbgen only creates the projects/ dir
andrew211 16:12 gotcha; ill do these changes as indicated on the version page using a text editor, then run prep script when I think it should work
taxilian 16:12 if you run into other probs you can't figure out let us know; I may or may not be here since I'm going to go play some frisbee in about an hour, but I'll be online all day tomorrow again (I'm on GMT-0700)
andrew211 16:12 thanks mate; hopefully ill figure it out
taxilian 16:12 yeah; shouldn't be terrible. I try not to let many breaking changes in, but sometimes the only way to improve things is to fix old mistakes =]
andrew211 16:12 yeh sure
I did notice when I ran fbgen before with 1.6, the code generated was different slightly (new methods in the default API.cpp etc?) should I be doing that and porting changes across? I guess so
taxilian 16:12 there are some helper things
but they aren't critical
just look at the templates in fbgen/src/
see if there is anything you care about
andrew211 16:12 yep ta
woo, generated the sln files ok, gonna try a compile
taxilian 16:12 heh. prediction: you will have compile errors due to breaking changes :-P
andrew211 16:12 yup; shouldnt be too bad, I looked at the differences to a fbgen version before and it wasn't that much
can I suggest btw adding the tips of laying out where fb is installed; and that everything can be regenerated (ie dont version it); and to only need to version your source? I originally just versioned everything, unsure which parts were my code and that wouldnt be regenerated etc
taxilian 16:12 well, I normally use git for everything
which means I can use submodules
I actually put firebreath as a submodule inside my project dir
so I run firebreath\prep2010.cmd . build
but you can also just version your project directory and then put firebreath as a sibling dir
firebreath\prep2010.cmd myProject myProject_build
or something
see also
andrew211 16:12 debug built ok; trying release!
just had to fix shared_ptr() call
taxilian 17:12 that's nto bad
andrew211 17:12 I made an fbgen plugin with 1.6, just comparing its code to mine
I notice things like ThePluginName's destructor isnt calling releaseRootJSAPI() etc in my version
so ill merge across all of those changes I think to be safe
taxilian 17:12 probably a good idea
that isn't strictly necessary, but it does help clarify the lifecycle a bit
andrew211 17:12 all done; just sorting out my source control now
again, thanks for the help (and great product)
taxilian 17:12 you're welcome; if you want to thank us properly please contribute in whatever way you can (contribute docs, donate, contribute code/patches, help with projects, blog about us, tweet about us, etc)
lots of options =]
andrew211 17:12 will do; I think I donated to you guys 6 months ago or whenever I found this project hehe
taxilian 17:12 hmm; not seeing an andrew on the list; maybe I didn't get the confirmation copied into teh right folder
andrew211 17:12 [email protected] was my email at the time
ill dig up a receipt if your curious :)
taxilian 17:12 ahh, I see it
I sure appreciate it, then; if I'd known you were phpplasma I would have helped even more enthusiastically =]
andrew211 17:12 np's
andrew211 18:12 outta here, thanks for the help
taxilian 22:12 linearray: you're not going to believe this
but all of that hassle we went through? pretty much unneccesary
it doesn't need to be synchronous because it has a callback
and since all you need to do is put it on the main event loop but not as part of a plugin call, and because of how FireBreath does async callbacks on Mac, you can just call the dialog opening function using host->ScheduleOnMainThread