Skip to content

Commit 7414aa2

Browse files
authored
Fixes wasm (#54) (#55)
* refer to the generic module * from qt6.6.0 malloc and free are in the js API
1 parent 80fad4e commit 7414aa2

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

QtQrDec/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ if (Qt6_FOUND AND TARGET QrDec)
1313
URI QtQrDec
1414
VERSION 1.0
1515
SOURCES Qrimagedecoder.cpp include/Qrimagedecoder.hpp
16-
QML_FILES
17-
qml/QrQmlCamera.qml
16+
QML_FILES
17+
qml/QrQmlCamera.qml
1818
qml/QrCam.qml
1919
qml/QrTextCamPop.qml
2020
RESOURCE_PREFIX
@@ -24,10 +24,11 @@ if (Qt6_FOUND AND TARGET QrDec)
2424
${CMAKE_BINARY_DIR}/QtQrDec
2525
IMPORT_PATH ${CMAKE_BINARY_DIR}
2626
)
27+
2728
target_include_directories(QtQrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2829
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")
2930

30-
target_link_libraries(QtQrDec PUBLIC Qt6::Gui Qt6::Quick QrDec $<TARGET_NAME_IF_EXISTS:Qt6::Multimedia> MyDesigns
31+
target_link_libraries(QtQrDec PUBLIC Qt6::Gui Qt6::Quick QrDec $<TARGET_NAME_IF_EXISTS:Qt6::Multimedia> MyDesigns
3132
$<$<STREQUAL:$<TARGET_PROPERTY:MyDesigns,TYPE>,STATIC_LIBRARY>:MyDesignsplugin>)
3233

3334
install(TARGETS QtQrDec QtQrDecplugin ${out_targets_var}
@@ -45,6 +46,6 @@ if (Qt6_FOUND AND TARGET QrDec)
4546
)
4647

4748
if(EMSCRIPTEN)
48-
target_compile_definitions(QtQrDec PUBLIC USE_EMSCRIPTEN)
49+
target_compile_definitions(QtQrDec PRIVATE USE_EMSCRIPTEN)
4950
endif(EMSCRIPTEN)
5051
endif(Qt6_FOUND AND TARGET QrDec)

QtQrDec/Qrimagedecoder.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ EM_JS(void, js_start, (), {
4141
let canvas = document.querySelector("#qrcanvas");
4242
let ctx=canvas.getContext("2d");
4343
const processFrame = function () {
44-
//You need to define qtQR module when loading the module of the qt application.
4544
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
4645
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
4746
const sourceBuffer = imageData.data;
48-
const buffer = qtQR._malloc(sourceBuffer.byteLength);
49-
qtQR.HEAPU8.set(sourceBuffer, buffer);
50-
qtQR.QRImageDecoder.getdecoder().reload(buffer,video.width,video.height);
51-
qtQR._free(buffer);
47+
const buffer = _malloc(sourceBuffer.byteLength);
48+
HEAPU8.set(sourceBuffer, buffer);
49+
Module.QRImageDecoder.getdecoder().reload(buffer,video.width,video.height);
50+
_free(buffer);
5251
if(window.localStream.active)
5352
{
5453
requestAnimationFrame(processFrame);

0 commit comments

Comments
 (0)