[dasher] Avoid loading nonexistent training text.



commit 120457dfbd7ae76516d629404003906beb3b1c48
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Sat Dec 5 14:47:46 2009 +0000

    Avoid loading nonexistent training text.

 ChangeLog                              |    4 ++++
 Src/DasherCore/NodeCreationManager.cpp |   28 +++++++++++++++++-----------
 2 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c92b59e..a7c495d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-12-05  Alan Lawrence <acl33 inf phy cam ac uk>
+
+	* Avoid loading nonexistent training text
+
 2009-12-05  Patrick Welche <prlw1 cam ac uk>
 
 	* Fix Visual Studio 2005 build
diff --git a/Src/DasherCore/NodeCreationManager.cpp b/Src/DasherCore/NodeCreationManager.cpp
index c5ac6d0..1c9228e 100644
--- a/Src/DasherCore/NodeCreationManager.cpp
+++ b/Src/DasherCore/NodeCreationManager.cpp
@@ -91,17 +91,23 @@ CNodeCreationManager::CNodeCreationManager(Dasher::CDasherInterfaceBase *pInterf
   else
     m_pAlphabetManager = new CAlphabetManager(pInterface, this, m_pLanguageModel);
 
-  //1. Look for system training text...
-  CLockEvent oEvent("Training on System Text", true, 0);
-  pEventHandler->InsertEvent(&oEvent);
-  m_pTrainer->LoadFile(GetStringParameter(SP_SYSTEM_LOC) + m_pAlphabet->GetTrainingFile());
-  //Now add in any user-provided individual training text...
-  oEvent.m_strMessage = "Training on User Text"; oEvent.m_bLock=true; oEvent.m_iPercent = 0;
-  pEventHandler->InsertEvent(&oEvent);
-  m_pTrainer->LoadFile(GetStringParameter(SP_USER_LOC) + m_pAlphabet->GetTrainingFile());
-  oEvent.m_bLock = false;
-  pEventHandler->InsertEvent(&oEvent);
-
+  if (!m_pAlphabet->GetTrainingFile().empty()) {
+    //1. Look for system training text...
+    CLockEvent oEvent("Training on System Text", true, 0);
+    pEventHandler->InsertEvent(&oEvent);
+    m_pTrainer->LoadFile(GetStringParameter(SP_SYSTEM_LOC) + m_pAlphabet->GetTrainingFile());
+    //Now add in any user-provided individual training text...
+    oEvent.m_strMessage = "Training on User Text"; oEvent.m_bLock=true; oEvent.m_iPercent = 0;
+    pEventHandler->InsertEvent(&oEvent);
+    m_pTrainer->LoadFile(GetStringParameter(SP_USER_LOC) + m_pAlphabet->GetTrainingFile());
+    oEvent.m_bLock = false;
+    pEventHandler->InsertEvent(&oEvent);
+  }
+#ifdef DEBUG
+  else {
+    std::cout << "Alphabet does not specify training file" << std::endl;
+  }
+#endif
 #ifdef DEBUG_LM_READWRITE
   {
     //test...



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]