using boost::thread will hide or not show the child window.

39 views
Skip to first unread message

Yoganathan Venkatesan

unread,
May 29, 2013, 10:05:30 AM5/29/13
to firebre...@googlegroups.com

To response to javascript function in timely manner from plugin I have used boost thread. Its working fine as expected but when I call Invalidate rect to update the child window (It will show the images) Its just flashed and disappeared. Below is my code.. please suggest what would be the procedure to do this task.

BOOL MyPluginAPI::openFile(FB::JSObjectPtr &callback){
    boost::thread t(boost::bind(&MyPluginAPI::t_openFile, this, callback));
    return true;
}

void MyPluginAPI::t_openFile(FB::JSObjectPtr &callback){
    twainAPI->openFile(g_hWnd);
    callback->InvokeAsync("", FB::variant_list_of(shared_from_this()));   
}

Thanks,
Yoga V

Richard Bateman

unread,
May 29, 2013, 10:35:20 AM5/29/13
to firebre...@googlegroups.com

Are you returning "true" from your RefreshEvent handler? If you are drawing, then you should be returning true; otherwise FireBreath will try to draw the default layout. You haven't included any code that seems to be in any way related to drawing, so it's impossible to speculate beyond that one guess.

If you want more help, you need to provide more information. I'm happy to help, but I'm not willing or interested to be a free service that writes code for you on demand =] Show me/us what you've tried, we'll see if we can help you figure out where you've gone wrong.  If you haven't tried (though it sounds like you have) then go and try some things before asking for help; you learn by doing.

Richard

--
 
---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Neil Griffiths

unread,
May 29, 2013, 10:36:52 AM5/29/13
to firebre...@googlegroups.com
Your boost::thread t variable goes out of scope at the end of openFile so your thread gets destroyed.

Neil



--

Neil Griffiths

unread,
May 29, 2013, 10:38:33 AM5/29/13
to firebre...@googlegroups.com
Plus your t_openFile function is going to exit so your thread is going to end anyway.

Yoganathan Venkatesan

unread,
May 30, 2013, 2:51:30 AM5/30/13
to firebre...@googlegroups.com
Yes Richard... I have a draw function in plugincore class which will call refresh event like below.
bool MyPlugin::draw( FB::RefreshEvent *evt, FB::PluginWindow* win )
{   
    return true;
}
 
But In my scenario I used a child window to draw the selected images. So I have created the child window and called the invalidateRect with in openFile() function using below code.

InvalidateRect(hChildWin, NULL, true);

It was perfectly done its job well before boost::thread code used. After I used the boost::thread functionality in order to avoid "stop script" dialogue in firefox the child window is just flashed with the images and disappeared.

Thanks Richard and Neil for your suggestion.
 
Thanks,
Yoga V

Yoganathan Venkatesan

unread,
May 30, 2013, 9:48:59 AM5/30/13
to firebre...@googlegroups.com
There is no issue with InvokeAsync("", FB::variant_list_of(shared_from_this())); function. I created the child window after boost::thread called. Now I created the child window before calling boost::thread function. Now Its working well. I just patched the issue not solved because I could not find the exact problem.

Thanks,
Yoga V
Reply all
Reply to author
Forward
0 new messages