X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=src%2Fthreadrecon.cpp;fp=src%2Fthreadrecon.cpp;h=75861c492f3f6a8adb7cbab7fe5a1e9396e94383;hb=c7435da167c4cec94d9f2da0410b5f544bb4c54d;hp=820b44b75d70e2382e65a122c10d47e1ba53da49;hpb=fada6fda06c0b0127552ff8bcb169a737d1e828f;p=ctsim.git diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index 820b44b..75861c4 100644 --- a/src/threadrecon.cpp +++ b/src/threadrecon.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: threadrecon.cpp,v 1.9 2001/02/25 07:36:26 kevin Exp $ +** $Id: threadrecon.cpp,v 1.10 2001/02/25 08:00:57 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -221,47 +221,53 @@ ReconstructorWorker::Entry () *m_pImageFile, m_pszFilterName, m_dFilterParam, m_pszFilterMethod, m_iZeropad, m_pszFilterGenerationName, m_pszInterpName, m_iInterpParam, m_pszBackprojectName, Trace::TRACE_NONE); - wxCommandEvent eventDone (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_DONE); - eventDone.SetInt (m_iThread); // Send back thread# that has finished - - if (pReconstructor->fail()) { - wxString msg("Unable to make reconstructor: "); - msg += pReconstructor->failMessage().c_str(); + bool bFail = pReconstructor->fail(); + wxString failMsg; + if (bFail) { + failMsg = "Unable to make reconstructor: "; + failMsg += pReconstructor->failMessage().c_str(); wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - event.SetString( msg ); + event.SetString( failMsg ); wxPostEvent( theApp->getMainFrame(), event ); - - wxPostEvent (m_pSupervisor, eventDone); - return reinterpret_cast(-1); } - - wxCommandEvent eventProgress (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_UNIT_TICK); - - for (int iUnit = 0; iUnit < m_iNumUnits; iUnit++) { - if (TestDestroy()) { + else + { + wxCommandEvent eventProgress (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_UNIT_TICK); + for (int iUnit = 0; iUnit < m_iNumUnits; iUnit++) { + if (TestDestroy()) { #ifdef DEBUG - if (theApp->getVerboseLogging()) { - wxString msg; - msg.Printf("Worker thread: Received destroy message at work unit #%d\n", iUnit); - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - event.SetString( msg ); - wxPostEvent( theApp->getMainFrame(), event ); - } + if (theApp->getVerboseLogging()) { + wxString msg; + msg.Printf("Worker thread: Received destroy message at work unit #%d\n", iUnit); + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + event.SetString( msg ); + wxPostEvent( theApp->getMainFrame(), event ); + } #endif - delete pReconstructor; - wxPostEvent (m_pSupervisor, eventDone); - - return reinterpret_cast(-1); + break; + } + pReconstructor->reconstructView (iUnit + m_iStartUnit, 1); + m_pSupervisor->AddPendingEvent (eventProgress); } - pReconstructor->reconstructView (iUnit + m_iStartUnit, 1); - m_pSupervisor->AddPendingEvent (eventProgress); + pReconstructor->postProcessing(); } - pReconstructor->postProcessing(); delete pReconstructor; - wxPostEvent (m_pSupervisor, eventDone); + if (bFail) { + wxCommandEvent eventFail (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_FAIL); + eventFail.SetInt (m_iThread); // Send back thread# that has finished + eventFail.SetString (failMsg); + wxPostEvent (m_pSupervisor, eventFail); + } else { + wxCommandEvent eventDone (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_DONE); + eventDone.SetInt (m_iThread); // Send back thread# that has finished + wxPostEvent (m_pSupervisor, eventDone); + } - return reinterpret_cast(0); + while (! TestDestroy()) + Sleep(100); + + return reinterpret_cast(0); } void