mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 05:10:04 +00:00 
			
		
		
		
	Don't refresh text events until application is initialized (before signals are connected)
This commit is contained in:
		
							parent
							
								
									dabcf1114e
								
							
						
					
					
						commit
						e0dceda2d2
					
				
					 5 changed files with 81 additions and 3 deletions
				
			
		
							
								
								
									
										48
									
								
								scwx-qt/source/scwx/qt/main/application.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								scwx-qt/source/scwx/qt/main/application.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,48 @@ | |||
| #include <scwx/qt/main/application.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace main | ||||
| { | ||||
| namespace Application | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::qt::main::application"; | ||||
| static const auto        logger_    = util::Logger::Create(logPrefix_); | ||||
| 
 | ||||
| static std::mutex              initializationMutex_ {}; | ||||
| static std::condition_variable initializationCondition_ {}; | ||||
| static bool                    initialized_ {false}; | ||||
| 
 | ||||
| void FinishInitialization() | ||||
| { | ||||
|    logger_->debug("Application initialization finished"); | ||||
| 
 | ||||
|    // Set initialized to true
 | ||||
|    std::unique_lock lock(initializationMutex_); | ||||
|    initialized_ = true; | ||||
|    lock.unlock(); | ||||
| 
 | ||||
|    // Notify any threads waiting for initialization
 | ||||
|    initializationCondition_.notify_all(); | ||||
| } | ||||
| 
 | ||||
| void WaitForInitialization() | ||||
| { | ||||
|    std::unique_lock lock(initializationMutex_); | ||||
| 
 | ||||
|    // While not yet initialized
 | ||||
|    while (!initialized_) | ||||
|    { | ||||
|       // Wait for initialization
 | ||||
|       initializationCondition_.wait(lock); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| } // namespace Application
 | ||||
| } // namespace main
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										18
									
								
								scwx-qt/source/scwx/qt/main/application.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								scwx-qt/source/scwx/qt/main/application.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| #pragma once | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace main | ||||
| { | ||||
| namespace Application | ||||
| { | ||||
| 
 | ||||
| void FinishInitialization(); | ||||
| void WaitForInitialization(); | ||||
| 
 | ||||
| } // namespace Application
 | ||||
| } // namespace main
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
|  | @ -3,6 +3,7 @@ | |||
| #include "main_window.hpp" | ||||
| #include "./ui_main_window.h" | ||||
| 
 | ||||
| #include <scwx/qt/main/application.hpp> | ||||
| #include <scwx/qt/manager/radar_product_manager.hpp> | ||||
| #include <scwx/qt/manager/settings_manager.hpp> | ||||
| #include <scwx/qt/manager/text_event_manager.hpp> | ||||
|  | @ -207,6 +208,8 @@ MainWindow::MainWindow(QWidget* parent) : | |||
|    p->ConnectMapSignals(); | ||||
|    p->ConnectOtherSignals(); | ||||
|    p->HandleFocusChange(p->activeMap_); | ||||
| 
 | ||||
|    Application::FinishInitialization(); | ||||
| } | ||||
| 
 | ||||
| MainWindow::~MainWindow() | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| #include <scwx/qt/manager/text_event_manager.hpp> | ||||
| #include <scwx/qt/main/application.hpp> | ||||
| #include <scwx/awips/text_product_file.hpp> | ||||
| #include <scwx/provider/warnings_provider.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
|  | @ -33,7 +34,13 @@ public: | |||
|        textEventMutex_ {}, | ||||
|        warningsProvider_ {kDefaultWarningsProviderUrl} | ||||
|    { | ||||
|       util::async([=]() { Refresh(); }); | ||||
|       util::async( | ||||
|          [=]() | ||||
|          { | ||||
|             main::Application::WaitForInitialization(); | ||||
|             logger_->debug("Start Refresh"); | ||||
|             Refresh(); | ||||
|          }); | ||||
|    } | ||||
| 
 | ||||
|    ~Impl() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat