Commit 605d54e6 authored by Alexandru Croitor's avatar Alexandru Croitor
Browse files

Prevent Qt Quick Compiler from removing qrc Javascript source code


By default whenever a Qt application is built with Qt Quick compiler,
it will scan all qrc resources for javascript files, generate
corresponding C++ code, and remove the original JS code. This is
problematic for web pages that are loaded in WebEngine because the pages
won't be able to access the javascript code, and silently fail (or if
you are lucky, you will get some unrelated "can not be found" error).

Use the undocumented QtQuick Compiler
QTQUICK_COMPILER_SKIPPED_RESOURCES qmake variable to specify that
Javascript source code found in qrc files should be left as is.

Task-number: QTBUG-66155
Change-Id: Ib1dc744901baddd9e0c17c53db1ffede5c31e544
Reviewed-by: default avatarSimon Hausmann <simon.hausmann@qt.io>
Showing with 11 additions and 0 deletions
...@@ -10,6 +10,9 @@ SOURCES += main.cpp ...@@ -10,6 +10,9 @@ SOURCES += main.cpp
RESOURCES += resources/resources.qrc RESOURCES += resources/resources.qrc
# Make sure Qt Quick compiler does not remove the source code of the .js files.
QTQUICK_COMPILER_SKIPPED_RESOURCES = resources/resources.qrc
DISTFILES += \ DISTFILES += \
resources/pages/assets/3rdparty/MARKDOWN-LICENSE.txt \ resources/pages/assets/3rdparty/MARKDOWN-LICENSE.txt \
resources/pages/assets/3rdparty/MARKED-LICENSE.txt resources/pages/assets/3rdparty/MARKED-LICENSE.txt
......
...@@ -5,6 +5,10 @@ SOURCES = main.cpp \ ...@@ -5,6 +5,10 @@ SOURCES = main.cpp \
mainwindow.cpp mainwindow.cpp
RESOURCES = jquery.qrc RESOURCES = jquery.qrc
# Disable Qt Quick compiler because the example doesn't use QML, but more importantly so that
# the source code of the .js files is not removed from the embedded qrc file.
CONFIG -= qtquickcompiler
# install # install
target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/contentmanipulation target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/contentmanipulation
INSTALLS += target INSTALLS += target
...@@ -17,6 +17,10 @@ SOURCES = \ ...@@ -17,6 +17,10 @@ SOURCES = \
RESOURCES = \ RESOURCES = \
resources/markdowneditor.qrc resources/markdowneditor.qrc
# Disable Qt Quick compiler because the example doesn't use QML, but more importantly so that
# the source code of the .js files is not removed from the embedded qrc file.
CONFIG -= qtquickcompiler
FORMS += \ FORMS += \
mainwindow.ui mainwindow.ui
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment