From fb4d91996affdbcd3ffc19c7646fbf77b96bf1e5 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 23:10:59 +0000 Subject: Make sure we load translations on the main thread. Because the old implementation (accidentally) worked when you put the ecm_create_qm_loader call in a different CMakeLists.txt file to the target the file was added to, some projects did this. This won't work with build-time-generated files, though, like moc files. So we (ab)use QTimer events to make the loading happen on the main thread. BUG: 346188 REVIEW: 126000 --- tests/ECMPoQmToolsTest/CMakeLists.txt | 44 +++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'tests/ECMPoQmToolsTest/CMakeLists.txt') diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index 73d2b427..2cd76f8f 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -82,7 +82,7 @@ target_link_libraries(tr_test PRIVATE Qt5::Core) # -# single-threaded test (different catalog name) +# single-threaded test (different catalog name, automoc) # # This is to check we don't overwrite previously-generated files. set(tr_test_2_SRCS @@ -90,15 +90,55 @@ set(tr_test_2_SRCS ) ecm_create_qm_loader(tr_test_2_SRCS catalog2) add_executable(tr_test_2 ${tr_test_2_SRCS}) +set_target_properties(tr_test_2 PROPERTIES AUTOMOC ON) +target_include_directories(tr_test_2 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") target_link_libraries(tr_test_2 PRIVATE Qt5::Core) +# +# module for tr_thread_test +# +add_library(tr_thread_module MODULE tr_thread_test_module.cpp ${QMLOADER_FILES}) +target_link_libraries(tr_thread_module PRIVATE Qt5::Core) + + +# +# loading a module on a thread other than the main thread +# (automoc) +# +set(tr_thread_test_SRCS + tr_thread_test.cpp +) +ecm_create_qm_loader(tr_thread_test_SRCS catalog) +add_executable(tr_thread_test ${tr_thread_test_SRCS}) +set_target_properties(tr_thread_test PROPERTIES AUTOMOC ON) +target_include_directories(tr_thread_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") +target_compile_definitions(tr_thread_test PRIVATE "MODULE_PATH=\"$\"") +target_link_libraries(tr_thread_test PRIVATE Qt5::Core) + + +# +# loading a module on a thread other than the main thread +# (different catalog, no AUTOMOC) +# +qt5_generate_moc(tr_thread_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/tr_thread_test.moc") +set(tr_thread_test_2_SRCS + tr_thread_test.cpp + "${CMAKE_CURRENT_BINARY_DIR}/tr_thread_test.moc" +) +ecm_create_qm_loader(tr_thread_test_2_SRCS catalog2) +add_executable(tr_thread_test_2 ${tr_thread_test_2_SRCS}) +target_include_directories(tr_thread_test_2 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") +target_compile_definitions(tr_thread_test_2 PRIVATE "MODULE_PATH=\"$\"") +target_link_libraries(tr_thread_test_2 PRIVATE Qt5::Core) + + # # call to ecm_create_qm_loader is in a different CMakeLists.txt to where # the target it is added to is defined # # This is not something we want people to do, but it's unfortunately something -# projects have done and we need to keep them building +# projects have done and we need to keep them building. unset(QMLOADER_FILES) ecm_create_qm_loader(QMLOADER_FILES catalog) assert_var_defined(QMLOADER_FILES) -- cgit v1.2.1