Closed uniho closed 2 years ago
Hi,
You're right. The right argument data type for ICefv8Value.SetUserData() and ICefv8Value.GetUserData() should be ICefBaseRefCounted instead of ICefv8Value.
However, CEF has a very unique way to handle interfaces that breaks the Delphi definition of interface inheritance.
If we use ICefBaseRefCounted for SetUserData and GetUserData then we can't use "SysUtils.supports", "IInterface.QueryInterface" or "as" to get the right interface reference that we originally used with SetUserData.
Consider converting your user data to any of the supported data types that ICefv8Value can handle or try using an alternative method to pass that information.
Thanks for your quick reply! You mean we cannot know GC timing from native code like this thread says?
If you really need to know that then you can modify the ICefv8Value interface and the TCefv8ValueRef class declarations.
Set the data type for ICefv8Value.SetUserData() and ICefv8Value.GetUserData() with your own custom ICefBaseRefCounted descendant and send a message when the instance of that custom class is destroyed.
You will also have to remove the TCefRTTIExtension class because it uses ICefv8Value.SetUserData() and ICefv8Value.GetUserData() with the current data type.
Yeah, I want to create TProcess Object (I'm using Lazarus) on CefTask thread using JS Promise, to read stdin and stderr from pipe, and kill it on GC timing. I will try. It is kind of you!
I just remembered that you could also use the current ICefv8Value.SetUserData() and ICefv8Value.GetUserData() implementation and use TCefv8ValueRef.NewArrayBuffer to create a fake array with a user defined destruction callback function.
That callback will be called when the GC needs to destroy that array and you could also add extra code to send a message to the main browser process with your information.
Hi, new project launched! Thanks for your advice!
Can you change argument of ICefv8Value.SetUserData() and SetUserData() from ICefv8Value to ICefBaseRefCounted as CEF C++ API?