mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 22:53:43 +00:00
Cancel "Fetching repository" job properly when PCM is opened.
This commit is contained in:
parent
8df29a78e1
commit
883b615fef
@ -1082,6 +1082,22 @@ std::unordered_map<wxString, wxBitmap> PLUGIN_CONTENT_MANAGER::GetInstalledPacka
|
||||
}
|
||||
|
||||
|
||||
struct UPDATE_CANCELLER
|
||||
{
|
||||
UPDATE_CANCELLER( std::shared_ptr<BACKGROUND_JOB>& aJob ) : m_jobToCancel( aJob ) {};
|
||||
~UPDATE_CANCELLER()
|
||||
{
|
||||
if( m_jobToCancel )
|
||||
{
|
||||
Pgm().GetBackgroundJobMonitor().Remove( m_jobToCancel );
|
||||
m_jobToCancel.reset();
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<BACKGROUND_JOB>& m_jobToCancel;
|
||||
};
|
||||
|
||||
|
||||
void PLUGIN_CONTENT_MANAGER::RunBackgroundUpdate()
|
||||
{
|
||||
// If the thread is already running don't create it again
|
||||
@ -1093,6 +1109,8 @@ void PLUGIN_CONTENT_MANAGER::RunBackgroundUpdate()
|
||||
m_updateThread = std::thread(
|
||||
[this]()
|
||||
{
|
||||
UPDATE_CANCELLER canceller( m_updateBackgroundJob );
|
||||
|
||||
if( m_installed.size() == 0 )
|
||||
return;
|
||||
|
||||
@ -1149,9 +1167,6 @@ void PLUGIN_CONTENT_MANAGER::RunBackgroundUpdate()
|
||||
return;
|
||||
}
|
||||
|
||||
Pgm().GetBackgroundJobMonitor().Remove( m_updateBackgroundJob );
|
||||
m_updateBackgroundJob = nullptr;
|
||||
|
||||
// Update the badge on PCM button
|
||||
m_availableUpdateCallback( availableUpdateCount );
|
||||
} );
|
||||
|
Loading…
Reference in New Issue
Block a user