[dasher] Fix PropertySheet() throwing an exception when opening preferences.



commit 38cbbf77e3a60d4dc01ff9fec5b3d4b0074f9b8f
Author: Patrick Welche <prlw1 cam ac uk>
Date:   Sun Feb 3 00:38:21 2013 +0000

    Fix PropertySheet() throwing an exception when opening preferences.
    
    The underlying problem was in DasherWindow.cpp:
      m_pAppSettings->SetDasher(m_pDasher);
    but m_pDasher was still NULL.
    
    XXXPW: comment out BP_GAME_MODE cases for now to allow compilation.

 Src/Win32/AppSettings.cpp  |    1 +
 Src/Win32/AppSettings.h    |    2 +-
 Src/Win32/Dasher.cpp       |   12 ++++++------
 Src/Win32/DasherWindow.cpp |   17 ++++++++++-------
 4 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/Src/Win32/AppSettings.cpp b/Src/Win32/AppSettings.cpp
index 33ed465..cce7f95 100644
--- a/Src/Win32/AppSettings.cpp
+++ b/Src/Win32/AppSettings.cpp
@@ -154,6 +154,7 @@ void CAppSettings::ResetParamater(int iParameter) {
 void CAppSettings::GetPermittedValues(int iParameter, vector<string> &vList) {
   //Don't think there are any app-specific string parameters with permitted values?
   DASHER_ASSERT(iParameter>=FIRST_SP && iParameter < END_OF_SPS);
+  DASHER_ASSERT(m_pDasher != NULL);
   m_pDasher->GetPermittedValues(iParameter,vList);
 }
 
diff --git a/Src/Win32/AppSettings.h b/Src/Win32/AppSettings.h
index 6519f35..f238de1 100644
--- a/Src/Win32/AppSettings.h
+++ b/Src/Win32/AppSettings.h
@@ -93,7 +93,7 @@ private:
   Dasher::CDasher *m_pDasher;
   HWND m_hWnd;
 
-   bool LoadSetting(const std::string & Key, bool * Value);
+  bool LoadSetting(const std::string & Key, bool * Value);
   bool LoadSetting(const std::string & Key, long *Value);
   bool LoadSetting(const std::string & Key, std::string * Value);
   bool LoadSettingT(const std::string & Key, Tstring * Value);
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index 4816a9b..4918477 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -148,11 +148,11 @@ unsigned int Dasher::CDasher::ctrlDelete(bool bForwards, CControlManager::EditDi
 
 // Gets the size of the window in screen coordinates.  
 bool Dasher::CDasher::GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight) {
-	if ((pTop == NULL) || (pLeft == NULL) || (pBottom == NULL) || (pRight == NULL))
-		return false;
+  if ((pTop == NULL)||(pLeft == NULL)||(pBottom == NULL)||(pRight == NULL))
+    return false;
 
-	RECT sWindowRect;
-	if (GetWindowRect(m_hParent, &sWindowRect))
+  RECT sWindowRect;
+  if (GetWindowRect(m_hParent, &sWindowRect))
   {
     *pTop    = sWindowRect.top;
     *pLeft   = sWindowRect.left;
@@ -185,7 +185,7 @@ void Dasher::CDasher::WriteTrainFile(const std::string &filename, const std::str
     DWORD NumberOfBytesWritten;
     SetFilePointer(hFile, 0, NULL, FILE_END);
 
-  //// Surely there are better ways to write to files than this??
+  // Surely there are better ways to write to files than this??
 
     for(unsigned int i = 0; i < strNewText.size(); i++) {
       WriteFile(hFile, &strNewText[i], 1, &NumberOfBytesWritten, NULL);
@@ -226,7 +226,7 @@ void CDasher::ScanFiles(AbstractParser *parser, const std::string &strPattern) {
   Tstring AppData;
   GetAppDirectory(&AppData);
   AppData += TEXT("system.rc\\");
-  CreateDirectory(AppData.c_str(), NULL);       // to do any harm if they already exist.
+  CreateDirectory(AppData.c_str(), NULL);// TODO: Any harm if they already exist
   string sysDir;
   wstring_to_UTF8string(AppData,sysDir);
   AppData += pattern;
diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp
index 3ab808a..ae3ed6b 100644
--- a/Src/Win32/DasherWindow.cpp
+++ b/Src/Win32/DasherWindow.cpp
@@ -93,13 +93,6 @@ HWND CDasherWindow::Create() {
   hWnd = CWindowImpl<CDasherWindow, CWindow, CWinTraits<WS_CLIPCHILDREN | WS_CLIPSIBLINGS> >::Create(NULL);
 #endif
 
-
-
-
-  // Create a CAppSettings
-  m_pAppSettings->SetHwnd(hWnd);
-  m_pAppSettings->SetDasher(m_pDasher);
-
   // Create Widgets
   m_pEdit = new CEdit(m_pAppSettings);
   m_pEdit->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP));
@@ -107,6 +100,10 @@ HWND CDasherWindow::Create() {
  
   m_pDasher = new CDasher(hWnd, this, m_pEdit);
 
+  // Create a CAppSettings
+  m_pAppSettings->SetHwnd(hWnd);
+  m_pAppSettings->SetDasher(m_pDasher);
+
 #ifdef PJC_EXPERIMENTAL
   g_hWnd = m_pEdit->GetHwnd();
 #endif
@@ -222,11 +219,14 @@ void CDasherWindow::HandleParameterChange(int iParameter) {
   case LP_MAX_BITRATE:
     // TODO: reimplement
     break;
+// XXXPW
+#if 0
   case BP_GAME_MODE: {
 	  int iNewState(m_pDasher->GetBoolParameter(BP_GAME_MODE) ? MF_CHECKED : MF_UNCHECKED);
 	  DWORD iPrevState = CheckMenuItem(m_hMenu, ID_GAMEMODE, MF_BYCOMMAND | iNewState);
 	  DASHER_ASSERT( iPrevState != -1 ); //-1 = item does not exist (i.e. params to previous incorrect!)
   }
+#endif
   default:
     break;
   }
@@ -263,12 +263,15 @@ LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOO
     HtmlHelp(m_hWnd, L"Dasher.chm", HH_DISPLAY_INDEX, NULL);
     return 0;
 #endif
+// XXXPW
+#if 0
   case ID_GAMEMODE: {
 	  unsigned int checkState(GetMenuState(m_hMenu, ID_GAMEMODE, MF_BYCOMMAND));
 	  DASHER_ASSERT(checkState==-1); //"specified item does not exist" - presumably, params to above aren't right...
 	  m_pDasher->SetBoolParameter(BP_GAME_MODE, (checkState & MF_CHECKED) ? false : true);
     return 0;
   }
+#endif
   case IDM_EXIT:
     DestroyWindow();
     return 0;


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