From 6e18844035d9c5e25d770ed817b858c2423d894b Mon Sep 17 00:00:00 2001
From: Konstantin Tokarev <annulen@yandex.ru>
Date: Sun, 20 Sep 2020 16:06:43 +0300
Subject: [PATCH] [WK2][QML] Fix crash in dynamic_cast when using WebView.icon
 with Qt >= 5.13

Change-Id: Iebe7b7a95f7bcc3a502d4589bf36a594c92c0395
---
 Source/WebKit/qt/declarative/CMakeLists.txt         |  4 ++++
 .../qt/declarative/experimental/CMakeLists.txt      |  4 ++++
 Source/WebKit2/PlatformQt.cmake                     | 13 +++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/Source/WebKit/qt/declarative/CMakeLists.txt b/Source/WebKit/qt/declarative/CMakeLists.txt
index e1ba22bc14b68..d6bbf841b9228 100644
--- a/Source/WebKit/qt/declarative/CMakeLists.txt
+++ b/Source/WebKit/qt/declarative/CMakeLists.txt
@@ -42,6 +42,10 @@ set_target_properties(qmlwebkitplugin PROPERTIES
     AUTOMOC ON
 )
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    target_compile_options(qmlwebkitplugin PRIVATE -frtti)
+endif ()
+
 add_custom_target(
     qmlwebkitplugin-files ALL
     COMMAND ${CMAKE_COMMAND} -E copy_if_different qmldir "${CMAKE_BINARY_DIR}/imports/QtWebKit/qmldir"
diff --git a/Source/WebKit/qt/declarative/experimental/CMakeLists.txt b/Source/WebKit/qt/declarative/experimental/CMakeLists.txt
index 1526e6f47b03b..c2b0efad9262e 100644
--- a/Source/WebKit/qt/declarative/experimental/CMakeLists.txt
+++ b/Source/WebKit/qt/declarative/experimental/CMakeLists.txt
@@ -19,6 +19,10 @@ set_target_properties(qmlwebkitexperimentalplugin PROPERTIES
     AUTOMOC ON
 )
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    target_compile_options(qmlwebkitexperimentalplugin PRIVATE -frtti)
+endif ()
+
 add_custom_target(
     qmlwebkitexperimentalplugin-files ALL
     COMMAND ${CMAKE_COMMAND} -E copy_if_different qmldir "${CMAKE_BINARY_DIR}/imports/QtWebKit/experimental/qmldir"
diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake
index e920902f4a485..f233e3cd920e7 100644
--- a/Source/WebKit2/PlatformQt.cmake
+++ b/Source/WebKit2/PlatformQt.cmake
@@ -217,6 +217,19 @@ list(APPEND WebKit2_SOURCES
     WebProcess/qt/WebProcessQt.cpp
 )
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    set_source_files_properties(
+        UIProcess/API/qt/qquicknetworkreply.cpp
+        UIProcess/API/qt/qquicknetworkrequest.cpp
+        UIProcess/API/qt/qquickurlschemedelegate.cpp
+        UIProcess/API/qt/qquickwebpage.cpp
+        UIProcess/API/qt/qquickwebview.cpp
+        UIProcess/API/qt/qwebiconimageprovider.cpp
+    PROPERTIES
+        COMPILE_FLAGS -frtti
+    )
+endif ()
+
 qt5_add_resources(WebKit2_SOURCES
     WebKit2.qrc
 )
