Error with using CefCreateClosureTask

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Error with using CefCreateClosureTask

Postby glaran » Tue Jun 21, 2016 5:29 am

Hi guys,

Part of my code look like this:

Code: Select all
CefCookie cookie;
CefRefPtr< CefCookieManager > cookieManager = CefCookieManager::GetGlobalManager(NULL);
CefRefPtr<CefSetCookieCallback> callback = new EmptySetCookieCallback();
std::wstring httpUrl(HTTP);

//...

CefPostTask(TID_UI, CefCreateClosureTask(base::Bind(&CefCookieManager::SetCookie, cookieManager, CefString(httpUrl.c_str()), cookie, callback)));

But it gives error message when compiling:
3>********(1210) : error C2664: 'CefCreateClosureTask' : cannot convert parameter 1 from 'base::Callback<Sig>' to 'const base::Closure &'
3> with
3> [
3> Sig=bool (void)
3> ]
3> Reason: cannot convert from 'base::Callback<Sig>' to 'const base::Closure'
3> with
3> [
3> Sig=bool (void)
3> ]
3> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

I have used the combination of CefCreateClosureTask and base::Bind somewhere else in my project without error, only here. Can anyone help me fix the problem? Thanks
Last edited by glaran on Tue Jun 21, 2016 8:05 pm, edited 2 times in total.
glaran
Newbie
 
Posts: 6
Joined: Sun Jun 19, 2016 10:36 am

Re: Error with using CefCreateClosureTask

Postby magreenblatt » Tue Jun 21, 2016 10:29 am

You need to #include "include/base/cef_bind.h"
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Error with using CefCreateClosureTask

Postby glaran » Tue Jun 21, 2016 7:54 pm

Both #include "include/base/cef_bind.h" and #include "include/wrapper/cef_closure_task.h" were already included
glaran
Newbie
 
Posts: 6
Joined: Sun Jun 19, 2016 10:36 am

Re: Error with using CefCreateClosureTask

Postby magreenblatt » Tue Jun 21, 2016 9:11 pm

Ah. SetCookie returns a non-void result so you need to use base::IgnoreResult(&CefCookieManager::SetCookie)
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Error with using CefCreateClosureTask

Postby glaran » Tue Jun 21, 2016 11:16 pm

Amazing, work like charm!
Thanks magreenblatt!
glaran
Newbie
 
Posts: 6
Joined: Sun Jun 19, 2016 10:36 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 60 guests