+ProjectionFileDocument::~ProjectionFileDocument()
+{
+ for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin();
+ i != m_vecpBackgroundSupervisors.end(); i++) {
+ BackgroundSupervisor::cancelSupervisor(*i);
+ }
+
+ while (m_vecpBackgroundSupervisors.size() > 0)
+ ::wxYield();
+
+ delete m_pProjectionFile;
+}
+
+void
+ProjectionFileDocument::OnAddBackground (wxCommandEvent& event)
+{
+ BackgroundSupervisor* pSupervisor = reinterpret_cast<BackgroundSupervisor*>(event.GetClientData());
+ wxASSERT (pSupervisor != NULL);
+
+ wxCriticalSectionLocker locker (m_criticalSection);
+ if (pSupervisor)
+ m_vecpBackgroundSupervisors.push_back (pSupervisor);
+}
+
+void
+ProjectionFileDocument::OnRemoveBackground (wxCommandEvent& event)
+{
+ BackgroundSupervisor* pSupervisor = reinterpret_cast<BackgroundSupervisor*>(event.GetClientData());
+ wxASSERT (pSupervisor != NULL);
+
+ wxCriticalSectionLocker locker (m_criticalSection);
+ bool bFound = false;
+ for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin();
+ i != m_vecpBackgroundSupervisors.end();
+ i++)
+ if (*i == pSupervisor) {
+ m_vecpBackgroundSupervisors.erase(i);
+ bFound = true;
+ break;
+ }
+ if (! bFound)
+ sys_error (ERR_SEVERE, "Could not find background task [ProjectionFileDocument::removeBackgroundTask");
+}
+