Veto window closure during scanner discovery in the background.

This commit is contained in:
Saleem Edah-Tally
2025-07-13 20:24:50 +02:00
parent 0f286efe4c
commit c10aac922d
6 changed files with 46 additions and 7 deletions

View File

@@ -422,10 +422,9 @@ void XInsaneWidget::Setup(wxConfig * config, TimeredStatusBar * sb)
btnScan->Enable(false);
btnScan->Bind ( wxEVT_RIGHT_UP, &XInsaneWidget::OnBtnScanRightClick, this );
btnScan->Bind ( wxEVT_LEFT_UP, &XInsaneWidget::OnBtnScanClick, this );
m_backgroundScannerDiscoveryEvh = std::make_unique<BackgroundScannerDiscoveryEVH>(this);
BackgroundScannerDiscovery * backgroundDiscovery = new BackgroundScannerDiscovery ( m_scannerWidget.get(),
m_backgroundScannerDiscoveryEvh.get());
backgroundDiscovery->Run();
m_backgroundDiscovery = new BackgroundScannerDiscovery ( m_scannerWidget.get(),
new BackgroundScannerDiscoveryEVH(this)); // Takes ownership.
m_backgroundDiscovery->Run();
}
@@ -581,5 +580,14 @@ void XInsaneWidget::CancelScanning()
void XInsaneWidget::EnableScanButton(bool enable)
{
// Called from BackgroundScannerDiscoveryEVH::Done() only;
btnScan->Enable(enable);
m_backgroundDiscovery = nullptr;
}
bool XInsaneWidget::IsScannerDiscoveryRunning()
{
if (!m_backgroundDiscovery)
return false;
return m_backgroundDiscovery->IsRunning();
}