mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:40:05 +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
|
|
@ -37,8 +37,10 @@ find_package(Qt${QT_VERSION_MAJOR}
|
||||||
|
|
||||||
set(SRC_EXE_MAIN source/scwx/qt/main/main.cpp)
|
set(SRC_EXE_MAIN source/scwx/qt/main/main.cpp)
|
||||||
|
|
||||||
set(HDR_MAIN source/scwx/qt/main/main_window.hpp)
|
set(HDR_MAIN source/scwx/qt/main/application.hpp
|
||||||
set(SRC_MAIN source/scwx/qt/main/main_window.cpp)
|
source/scwx/qt/main/main_window.hpp)
|
||||||
|
set(SRC_MAIN source/scwx/qt/main/application.cpp
|
||||||
|
source/scwx/qt/main/main_window.cpp)
|
||||||
set(UI_MAIN source/scwx/qt/main/main_window.ui)
|
set(UI_MAIN source/scwx/qt/main/main_window.ui)
|
||||||
set(HDR_CONFIG source/scwx/qt/config/county_database.hpp
|
set(HDR_CONFIG source/scwx/qt/config/county_database.hpp
|
||||||
source/scwx/qt/config/radar_site.hpp)
|
source/scwx/qt/config/radar_site.hpp)
|
||||||
|
|
|
||||||
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 "main_window.hpp"
|
||||||
#include "./ui_main_window.h"
|
#include "./ui_main_window.h"
|
||||||
|
|
||||||
|
#include <scwx/qt/main/application.hpp>
|
||||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||||
#include <scwx/qt/manager/settings_manager.hpp>
|
#include <scwx/qt/manager/settings_manager.hpp>
|
||||||
#include <scwx/qt/manager/text_event_manager.hpp>
|
#include <scwx/qt/manager/text_event_manager.hpp>
|
||||||
|
|
@ -207,6 +208,8 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
p->ConnectMapSignals();
|
p->ConnectMapSignals();
|
||||||
p->ConnectOtherSignals();
|
p->ConnectOtherSignals();
|
||||||
p->HandleFocusChange(p->activeMap_);
|
p->HandleFocusChange(p->activeMap_);
|
||||||
|
|
||||||
|
Application::FinishInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <scwx/qt/manager/text_event_manager.hpp>
|
#include <scwx/qt/manager/text_event_manager.hpp>
|
||||||
|
#include <scwx/qt/main/application.hpp>
|
||||||
#include <scwx/awips/text_product_file.hpp>
|
#include <scwx/awips/text_product_file.hpp>
|
||||||
#include <scwx/provider/warnings_provider.hpp>
|
#include <scwx/provider/warnings_provider.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
@ -33,7 +34,13 @@ public:
|
||||||
textEventMutex_ {},
|
textEventMutex_ {},
|
||||||
warningsProvider_ {kDefaultWarningsProviderUrl}
|
warningsProvider_ {kDefaultWarningsProviderUrl}
|
||||||
{
|
{
|
||||||
util::async([=]() { Refresh(); });
|
util::async(
|
||||||
|
[=]()
|
||||||
|
{
|
||||||
|
main::Application::WaitForInitialization();
|
||||||
|
logger_->debug("Start Refresh");
|
||||||
|
Refresh();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
~Impl()
|
~Impl()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue