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 --- modules/ECMPoQmTools.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'modules/ECMPoQmTools.cmake') diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index 0af5b12f..2547df1a 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -28,8 +28,8 @@ # # ecm_create_qm_loader( ) # -# Generates a C++ file which ensures translations are automatically loaded at -# startup. The path of the .cpp file is appended to ````. +# Generates C++ code which ensures translations are automatically loaded at +# startup. The generated files are appended to ````. # # It assumes that the .qm file for the language code ```` is installed as # ``/locale//LC_MESSAGES/.qm``, where @@ -99,9 +99,16 @@ endfunction() function(ecm_create_qm_loader out_var catalog_name) - # catalog_name is used in ECMQmLoader.cpp.in - configure_file(${ECM_MODULE_DIR}/ECMQmLoader.cpp.in ECMQmLoader-${catalog_name}.cpp @ONLY) - set(${out_var} ${${out_var}} ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader-${catalog_name}.cpp PARENT_SCOPE) + set(loader_base ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader-${catalog_name}) + + set(QM_LOADER_CATALOG_NAME "${catalog_name}") + + configure_file( + ${ECM_MODULE_DIR}/ECMQmLoader.cpp.in + "${loader_base}.cpp" + @ONLY + ) + set(${out_var} "${${out_var}}" "${loader_base}.cpp" PARENT_SCOPE) endfunction() -- cgit v1.2.1