-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f12cd
commit 9149d39
Showing
2 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
diff --git a/fltk-webview-sys/webview/webview.h b/fltk-webview-sys/webview/webview.h | ||
index 01f81e6..622bfdf 100644 | ||
--- a/fltk-webview-sys/webview/webview.h | ||
+++ b/fltk-webview-sys/webview/webview.h | ||
@@ -22,6 +22,9 @@ | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
+ | ||
+#include <string> | ||
+ | ||
#ifndef WEBVIEW_H | ||
#define WEBVIEW_H | ||
|
||
@@ -715,6 +718,12 @@ inline id operator"" _str(const char *s, std::size_t) { | ||
return objc::msg_send<id>("NSString"_cls, "stringWithUTF8String:"_sel, s); | ||
} | ||
|
||
+inline std::string unique_name(std::string base) { | ||
+ static int name_counter = 0; | ||
+ base += std::to_string(name_counter++); | ||
+ return base; | ||
+} | ||
+ | ||
class cocoa_wkwebview_engine { | ||
public: | ||
cocoa_wkwebview_engine(bool debug, void *window) | ||
@@ -827,7 +836,7 @@ private: | ||
// default name in projects created with Xcode, and using the same name | ||
// causes objc_registerClassPair to crash. | ||
auto cls = objc_allocateClassPair((Class) "NSResponder"_cls, | ||
- "WebviewAppDelegate", 0); | ||
+ unique_name("WebviewAppDelegate").c_str(), 0); | ||
class_addProtocol(cls, objc_getProtocol("NSTouchBarProvider")); | ||
class_addMethod(cls, "applicationShouldTerminateAfterLastWindowClosed:"_sel, | ||
(IMP)(+[](id, SEL, id) -> BOOL { return 1; }), "c@:@"); | ||
@@ -850,7 +859,7 @@ private: | ||
} | ||
id create_script_message_handler() { | ||
auto cls = objc_allocateClassPair((Class) "NSResponder"_cls, | ||
- "WebkitScriptMessageHandler", 0); | ||
+ unique_name("WebkitScriptMessageHandler").c_str(), 0); | ||
class_addProtocol(cls, objc_getProtocol("WKScriptMessageHandler")); | ||
class_addMethod( | ||
cls, "userContentController:didReceiveScriptMessage:"_sel, | ||
@@ -868,7 +877,7 @@ private: | ||
} | ||
static id create_webkit_ui_delegate() { | ||
auto cls = | ||
- objc_allocateClassPair((Class) "NSObject"_cls, "WebkitUIDelegate", 0); | ||
+ objc_allocateClassPair((Class) "NSObject"_cls, unique_name("WebkitUIDelegate").c_str(), 0); | ||
class_addProtocol(cls, objc_getProtocol("WKUIDelegate")); | ||
class_addMethod( | ||
cls, | ||
@@ -2292,4 +2301,4 @@ WEBVIEW_API const webview_version_info_t *webview_version() { | ||
|
||
#endif /* WEBVIEW_HEADER */ | ||
#endif /* __cplusplus */ | ||
-#endif /* WEBVIEW_H */ | ||
\ No newline at end of file | ||
+#endif /* WEBVIEW_H */ |