Compile error calling CefPostTask. CefTask/OnceClosure mixup

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.

Compile error calling CefPostTask. CefTask/OnceClosure mixup

Postby talbotmcinnis » Wed Sep 13, 2023 12:38 pm

I have a process on my own thread which would like to trigger a shutdown of all browsers and the core. I've written this:

Code: Select all
void CloseAllBrowsers(bool force_close)
{
   if (!CefCurrentlyOn(TID_UI)) {
      
      // Execute on the UI thread.
      base::OnceClosure callback = base::BindOnce(&CloseAllBrowsers, force_close);
      CefPostTask(TID_UI, callback);
      return;
   }

   for (unsigned int t = 0; t < WebRenderServiceIPC::BUFFER_HEADER::NUM_TABS; t++)
      g_acpBrowsers[t]->GetHost()->CloseBrowser(force_close);
   CefQuitMessageLoop();
}


I've compared to examples and tons of web code, and I don't see the issue with my usage of BindOnce, however I am getting a compile-time error:

Error C2664 'bool CefPostTask(CefThreadId,scoped_refptr<CefTask>)': cannot convert argument 2 from 'base::OnceClosure' to 'scoped_refptr<CefTask>'

Peeking header files, it is true that CefPostTask requires a CefTask. What am I missing to get my OnceClosure to function as a scoped_refptr<CefTask>?

Tried a few versions, but currently using cef_sdk 116.0.19 from nuget, in c++ obviously.
talbotmcinnis
Newbie
 
Posts: 2
Joined: Thu Aug 28, 2014 5:05 pm

Re: Compile error calling CefPostTask. CefTask/OnceClosure m

Postby magreenblatt » Wed Sep 13, 2023 1:41 pm

You need to include "include/wrapper/cef_closure_task.h". See that file for usage instructions/examples.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Compile error calling CefPostTask. CefTask/OnceClosure m

Postby talbotmcinnis » Wed Sep 13, 2023 1:59 pm

You are the god of all things CEF. Working. Thank you!!!!!!
talbotmcinnis
Newbie
 
Posts: 2
Joined: Thu Aug 28, 2014 5:05 pm


Return to Support Forum

Who is online

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