From 9710d4aacf801d3dc7ab243bc2c8e051a65871a6 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 6 Apr 2019 12:39:33 +0200 Subject: Autogen: Move libuv loop from cmQtAutoGenerator to cmQtAutoGeneratorMocUic `cmQtAutoGenerator` automatically started a libuv loop in the constructor. The loop is needed in `cmQtAutoGeneratorMocUic`, but not in `cmQtAutoGeneratorRcc` (anymore). To avoid starting the loop in `cmQtAutoGeneratorRcc`, this patch moves the loop variables and startup code from `cmQtAutoGenerator` to `cmQtAutoGeneratorMocUic`. --- Source/cmQtAutoGenerator.cxx | 17 ++--------------- Source/cmQtAutoGenerator.h | 10 ---------- Source/cmQtAutoGeneratorMocUic.cxx | 14 +++++++++++++- Source/cmQtAutoGeneratorMocUic.h | 11 ++++++++++- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 83a00cf..f115016 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -657,22 +657,9 @@ void cmQtAutoGenerator::ReadOnlyProcessT::UVTryFinish() } } -cmQtAutoGenerator::cmQtAutoGenerator() -{ - // Initialize libuv loop - uv_disable_stdio_inheritance(); -#ifdef CMAKE_UV_SIGNAL_HACK - UVHackRAII_ = cm::make_unique(); -#endif - UVLoop_ = cm::make_unique(); - uv_loop_init(UVLoop()); -} +cmQtAutoGenerator::cmQtAutoGenerator() = default; -cmQtAutoGenerator::~cmQtAutoGenerator() -{ - // Close libuv loop - uv_loop_close(UVLoop()); -} +cmQtAutoGenerator::~cmQtAutoGenerator() = default; bool cmQtAutoGenerator::Run(std::string const& infoFile, std::string const& config) diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 862b18d..479d357 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -8,7 +8,6 @@ #include "cmFilePathChecksum.h" #include "cmQtAutoGen.h" #include "cmUVHandlePtr.h" -#include "cmUVSignalHackRAII.h" // IWYU pragma: keep #include "cm_uv.h" #include @@ -249,9 +248,6 @@ public: std::string const& InfoFile() const { return InfoFile_; } std::string const& InfoDir() const { return InfoDir_; } std::string const& InfoConfig() const { return InfoConfig_; } - // libuv loop - uv_loop_t* UVLoop() { return UVLoop_.get(); } - cm::uv_async_ptr& UVRequest() { return UVRequest_; } // -- Utility static std::string SettingsFind(std::string const& content, const char* key); @@ -266,12 +262,6 @@ private: std::string InfoFile_; std::string InfoDir_; std::string InfoConfig_; -// -- libuv loop -#ifdef CMAKE_UV_SIGNAL_HACK - std::unique_ptr UVHackRAII_; -#endif - std::unique_ptr UVLoop_; - cm::uv_async_ptr UVRequest_; }; #endif diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 32e5067..ec1a1aa 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -1148,11 +1148,23 @@ cmQtAutoGeneratorMocUic::cmQtAutoGeneratorMocUic() Uic_.RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); + // Initialize libuv loop + uv_disable_stdio_inheritance(); +#ifdef CMAKE_UV_SIGNAL_HACK + UVHackRAII_ = cm::make_unique(); +#endif + UVLoop_ = cm::make_unique(); + uv_loop_init(UVLoop()); + // Initialize libuv asynchronous iteration request UVRequest().init(*UVLoop(), &cmQtAutoGeneratorMocUic::UVPollStage, this); } -cmQtAutoGeneratorMocUic::~cmQtAutoGeneratorMocUic() = default; +cmQtAutoGeneratorMocUic::~cmQtAutoGeneratorMocUic() +{ + // Close libuv loop + uv_loop_close(UVLoop()); +} bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) { diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h index cc785a7..27d73a7 100644 --- a/Source/cmQtAutoGeneratorMocUic.h +++ b/Source/cmQtAutoGeneratorMocUic.h @@ -8,6 +8,7 @@ #include "cmQtAutoGen.h" #include "cmQtAutoGenerator.h" #include "cmUVHandlePtr.h" +#include "cmUVSignalHackRAII.h" // IWYU pragma: keep #include "cm_uv.h" #include "cmsys/RegularExpression.hxx" @@ -390,6 +391,9 @@ private: // -- Utility accessors Logger& Log() { return Logger_; } FileSystem& FileSys() { return FileSys_; } + // -- libuv loop accessors + uv_loop_t* UVLoop() { return UVLoop_.get(); } + cm::uv_async_ptr& UVRequest() { return UVRequest_; } // -- Abstract processing interface bool Init(cmMakefile* makefile) override; bool Process() override; @@ -417,7 +421,12 @@ private: BaseSettingsT Base_; MocSettingsT Moc_; UicSettingsT Uic_; - // -- Progress + // -- libuv loop +#ifdef CMAKE_UV_SIGNAL_HACK + std::unique_ptr UVHackRAII_; +#endif + std::unique_ptr UVLoop_; + cm::uv_async_ptr UVRequest_; StageT Stage_ = StageT::SETTINGS_READ; // -- Job queues std::mutex JobsMutex_; -- cgit v0.12