Fix wxWebKitCtrl::RunScript() return value.
Replace comparisons of the type name of the returned value with isKindOfClass: checks which are more reliable. Closes #14358. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71631 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -682,18 +682,20 @@ wxString wxWebKitCtrl::RunScript(const wxString& javascript){
|
|||||||
id result = [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )];
|
id result = [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )];
|
||||||
|
|
||||||
NSString* resultAsString;
|
NSString* resultAsString;
|
||||||
NSString* className = NSStringFromClass([result class]);
|
if ([result isKindOfClass:[NSNumber class]]){
|
||||||
if ([className isEqualToString:@"NSCFNumber"])
|
// __NSCFBoolean is a subclass of NSNumber
|
||||||
resultAsString = [NSString stringWithFormat:@"%@", result];
|
if (strcmp([result objCType], @encode(BOOL)) == 0){
|
||||||
else if ([className isEqualToString:@"NSCFString"])
|
if ([result boolValue])
|
||||||
resultAsString = result;
|
resultAsString = @"true";
|
||||||
else if ([className isEqualToString:@"NSCFBoolean"]){
|
else
|
||||||
if ([result boolValue])
|
resultAsString = @"false";
|
||||||
resultAsString = @"true";
|
}
|
||||||
else
|
else
|
||||||
resultAsString = @"false";
|
resultAsString = [NSString stringWithFormat:@"%@", result];
|
||||||
}
|
}
|
||||||
else if ([className isEqualToString:@"WebScriptObject"])
|
else if ([result isKindOfClass:[NSString class]])
|
||||||
|
resultAsString = result;
|
||||||
|
else if ([result isKindOfClass:[WebScriptObject class]])
|
||||||
resultAsString = [result stringRepresentation];
|
resultAsString = [result stringRepresentation];
|
||||||
else
|
else
|
||||||
return wxString(); // This can happen, see e.g. #12361.
|
return wxString(); // This can happen, see e.g. #12361.
|
||||||
|
Reference in New Issue
Block a user