mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
Improve cleanup and signal disconnection on teardown
Add explicit disconnection of signals and abort pending network replies in destructors and shutdown methods to prevent unwanted callbacks and threading issues during object destruction or shutdown. This enhances robustness and safety, especially in asynchronous and multi-threaded contexts.
This commit is contained in:
1 parent
94c3059fd8
commit
d9c26c2c6d
3 files changed
+27
No files matched your search
@@ -133,6 +133,16 @@ RiaCloudConnector::RiaCloudConnector( QObject* parent,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaCloudConnector::~RiaCloudConnector()
|
||||
{
|
||||
// Disconnect all signals to prevent callbacks during destruction
|
||||
if ( m_authCodeFlow )
|
||||
{
|
||||
m_authCodeFlow->disconnect();
|
||||
}
|
||||
|
||||
if ( m_networkAccessManager )
|
||||
{
|
||||
m_networkAccessManager->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -54,6 +54,17 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaOsduConnector::~RiaOsduConnector()
|
||||
{
|
||||
// Abort all pending network replies to prevent threading issues during destruction
|
||||
QMutexLocker lock( &m_repliesMutex );
|
||||
for ( auto& [id, reply] : m_replies )
|
||||
{
|
||||
if ( !reply.isNull() )
|
||||
{
|
||||
reply->disconnect();
|
||||
reply->abort();
|
||||
}
|
||||
}
|
||||
m_replies.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -184,6 +184,12 @@ void RiaOpenTelemetryManager::shutdown()
|
||||
m_healthTimer->stop();
|
||||
}
|
||||
|
||||
// Disconnect network manager to prevent callbacks during shutdown
|
||||
if ( m_networkAccessManager )
|
||||
{
|
||||
m_networkAccessManager->disconnect();
|
||||
}
|
||||
|
||||
// Flush pending events
|
||||
flushPendingEvents();
|
||||
|
||||
|
||||
Reference in new issue
Block a user