سؤال

I want to cast FB::variant to FB::JSObjectPtr. below is my code

void PluginAPI::Test(FB::variant testVariant)
 {
     FB::JSObjectPtr jsObject=testVariant.convert_cast< FB::JSObjectPtr>();
 }

the above casting throws the Access violation Exception. Please let me know for the solution.

هل كانت مفيدة؟

المحلول

I don't know why an access violation exception would be thrown, but in general the most likely reason for this would be that it isn't actually a javascript object that is getting passed in.

Why are you doing a convert_cast inside the function? Just rewrite the function to:

void PluginAPI::Test(const FB::JSObjectPtr& jsObject)
{
    // use it here
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top