This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Call "Reset Board" message box from the primary thread


This patch modifies the Run Tests dialog code in the wxWindows configtool
such that the "Reset Board" message box is always called by the main thread
rather than the worker thread which invokes GDB. This change is necessary
for correct operation under Linux. Operation under Windows is unaffected.

John Dallaway
eCosCentric Limited

--cut here--

Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/ChangeLog,v
retrieving revision 1.30
diff -u -5 -r1.30 ChangeLog
--- ChangeLog	5 Feb 2003 13:53:21 -0000	1.30
+++ ChangeLog	10 Feb 2003 16:11:29 -0000
@@ -1,5 +1,12 @@
+2003-02-10  John Dallaway  <jld@ecoscentric.com>
+
+	* standalone/wxwin/runtestsdlg.cpp,
+	  standalone/wxwin/runtestsdlg.h:
+	Call the "Reset Board" message box in the primary thread rather than
+	the worker thread for correct operation under Linux.
+
 2003-02-05  John Dallaway  <jld@ecoscentric.com>

 	* standalone/wxwin/configtooldoc.cpp,
 	  standalone/wxwin/platformeditordlg.cpp,
 	  standalone/wxwin/runtestsdlg.cpp:
Index: standalone/wxwin/runtestsdlg.cpp
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/runtestsdlg.cpp,v
retrieving revision 1.4
diff -u -5 -r1.4 runtestsdlg.cpp
--- standalone/wxwin/runtestsdlg.cpp	5 Feb 2003 13:53:22 -0000	1.4
+++ standalone/wxwin/runtestsdlg.cpp	10 Feb 2003 16:11:36 -0000
@@ -119,11 +119,10 @@
 ecRunTestsDialog::ecRunTestsDialog(wxWindow* parent):
     wxDialog(),
     m_runStatus(ecStopped),
     m_nNextToSubmit(-1),
     m_pResource(NULL),
-    m_nTestsToComplete(0),
     m_testsAreComplete(FALSE)
 {
     m_runTestsDialog = this;
 
     SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
@@ -358,14 +357,14 @@
             wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN);
             runButton->SetLabel(_("&Stop"));
             
             m_nNextToSubmit=0;
             m_output->AddLogMsg(_("Run started"));
-            
+
             SubmitTests();
         }
-    }    
+    }
 }

 wxString ecRunTestsDialog::TranslatePort(const wxString& port) const
 {
 #ifdef __WXGTK__
@@ -385,19 +384,27 @@
         return port;
 }

 void ecRunTestsDialog::SubmitTests()
 {
+    int iTest;
     int nResources=wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote ? wxMax(1,CTestResource::GetMatchCount (m_ep)):1;
     if(nResources>CeCosTest::InstanceCount){
-        if(m_nNextToSubmit >= m_executables->SelectedTestCount()){
+        if (m_nNextToSubmit >= m_executables->SelectedTestCount()){
+            m_runStatus = ecStopped;
+
+            wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN);
+            runButton->SetLabel(_("&Run"));
+            m_output->AddLogMsg(_("Run complete"));
+
+            delete m_pResource;
+            m_pResource=0;
             return;
         }
         ecRunTestsInfo *pInfo=new ecRunTestsInfo;
         pInfo->pTest=new CeCosTest(m_ep, m_executables->SelectedTest(m_nNextToSubmit++));
         pInfo->pSheet=this;
-        m_nTestsToComplete++;
         if(wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote){
             CeCosThreadUtils::RunThread(RunRemoteFunc,pInfo, (CeCosThreadUtils::CallbackProc*) RunCallback,_T("RunRemoteFunc"));
         } else {
             bool bRun=false;
             switch((ResetType)wxGetApp().GetSettings().GetRunTestsSettings().m_nReset){
@@ -429,10 +436,12 @@
                     }
                     break;
                 }
             }
             if(bRun){
+                if (1 < m_nNextToSubmit)
+                      m_output->AddLogMsg(_("Run continuing"));
                 CeCosThreadUtils::RunThread(RunLocalFunc, pInfo, (CeCosThreadUtils::CallbackProc*) RunCallback,_T("RunLocalFunc"));
             }
         }
     }
 }
@@ -480,29 +489,21 @@
 void ecRunTestsDialog::RunCallback(void *pParam)
 {
     ecRunTestsInfo *pInfo=(ecRunTestsInfo *)pParam;
     ecRunTestsDialog *pSheet=pInfo->pSheet;
     if (m_runTestsDialog) // Will be NULL if dialog has been closed & deleted
-    { 
+    {
         CeCosTest *pTest=pInfo->pTest;
 
         pInfo->pSheet->m_CS.Enter();
-
+
         pSheet->m_summary->AddResult(pTest);
         delete pTest;
-        
-        pSheet->m_nTestsToComplete--;
-        pSheet->SubmitTests();
-        
-        if(0==pSheet->m_nTestsToComplete)
-        {
-            delete pSheet->m_pResource;
-            pSheet->m_pResource=0;

-            // OnIdle will check this variable and reset the status and button label
-            pSheet->m_testsAreComplete = TRUE;
-        }
+        // OnIdle will check this variable and reset the status and button label
+        pSheet->m_testsAreComplete = TRUE;
+
         pInfo->pSheet->m_CS.Leave();
     }
     delete pInfo;
 }
 
@@ -511,17 +512,11 @@
     FlushBuffer();
 
     if (m_testsAreComplete)
     {
         m_testsAreComplete = FALSE;
-
-        m_runStatus = ecStopped;
-
-        wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN);
-        runButton->SetLabel(_("&Run"));
-        
-        m_output->AddLogMsg(_("Run complete"));
+        SubmitTests();
     }

     event.Skip();
 }

Index: standalone/wxwin/runtestsdlg.h
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/runtestsdlg.h,v
retrieving revision 1.4
diff -u -5 -r1.4 runtestsdlg.h
--- standalone/wxwin/runtestsdlg.h	15 Dec 2001 13:42:19 -0000	1.4
+++ standalone/wxwin/runtestsdlg.h	10 Feb 2003 16:11:36 -0000
@@ -136,11 +136,10 @@
     ecRunStatus                             m_runStatus;
     CeCosTest::ExecutionParameters          m_ep;
 	int                                     m_nNextToSubmit;
     CTestResource*                          m_pResource;
     CProperties                             m_prop;
-	int                                     m_nTestsToComplete;
     wxCriticalSection                       m_CS;
     static ecRunTestsDialog*                m_runTestsDialog;
     bool                                    m_testsAreComplete;

     // Output text by writing to the buffer and letting


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]