Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Building CB with CB issues

<< < (2/2)

MortenMacFly:

--- Quote from: Alpha on September 01, 2012, 02:21:17 pm ---
--- Code: ---+            wxLogNull logno;

--- End code ---

--- End quote ---
BTW: Are you aware that the wx guys do not recommend the use of wxLogNull all over the place? I think a better way would be to verify the file/path (whenever possible) before doing a file system based operation.

Alpha:

--- Quote from: MortenMacFly on September 02, 2012, 09:59:03 am ---BTW: Are you aware that the wx guys do not recommend the use of wxLogNull all over the place?

--- End quote ---
I seem to remember something like that :)...
Will switch to actual checks.

MortenMacFly:

--- Quote from: Alpha on September 02, 2012, 03:06:40 pm ---
--- Quote from: MortenMacFly on September 02, 2012, 09:59:03 am ---BTW: Are you aware that the wx guys do not recommend the use of wxLogNull all over the place?

--- End quote ---
I seem to remember something like that :)...

--- End quote ---
There are good reasons though to use wxLogNull. For example: If you are accessing multiple directories at once an would need to add endless checks or is you are using low-level function (like locale) where you simply don't know what path's these are going to access.

Alpha:

--- Code: ---Index: src/plugins/contrib/SpellChecker/Thesaurus.cpp
===================================================================
--- src/plugins/contrib/SpellChecker/Thesaurus.cpp (revision 8330)
+++ src/plugins/contrib/SpellChecker/Thesaurus.cpp (working copy)
@@ -58,6 +58,8 @@
     else
     {
         Manager::Get()->GetLogManager()->Log(_T("SpellChecker: Thesaurus files '") + idxpath + _T("' not found!"));
+        if (!wxDirExists(idxpath.BeforeLast(wxFILE_SEP_PATH)) || !wxDirExists(datpath.BeforeLast(wxFILE_SEP_PATH)))
+            return; // path does not exist, silence invalid directory warnings
         wxString altIdx = wxFindFirstFile(idxpath.BeforeLast(wxT('.')) + wxT("*.idx"), wxFILE); // "*_v2.idx"
         if (altIdx.IsEmpty()) // try again with more wildcards
         {
Index: src/plugins/contrib/SpellChecker/SpellCheckerConfig.cpp
===================================================================
--- src/plugins/contrib/SpellChecker/SpellCheckerConfig.cpp (revision 8330)
+++ src/plugins/contrib/SpellChecker/SpellCheckerConfig.cpp (working copy)
@@ -139,7 +139,7 @@
     dictPaths.Add(m_pPlugin->GetOnlineCheckerConfigPath());
     for (size_t i = 0; i < dictPaths.GetCount(); ++i)
     {
-        if (!wxFindFirstFile(dictPaths[i] + wxFILE_SEP_PATH + wxT("*.dic"), wxFILE).IsEmpty())
+        if (wxDirExists(dictPaths[i]) && !wxFindFirstFile(dictPaths[i] + wxFILE_SEP_PATH + wxT("*.dic"), wxFILE).IsEmpty())
             return dictPaths[i];
     }
     return dictPaths[0];
@@ -172,7 +172,7 @@
     thesPaths.Add(m_pPlugin->GetOnlineCheckerConfigPath());
     for (size_t i = 0; i < thesPaths.GetCount(); ++i)
     {
-        if (!wxFindFirstFile(thesPaths[i] + wxFILE_SEP_PATH + wxT("th*.dat"), wxFILE).IsEmpty())
+        if (wxDirExists(thesPaths[i]) && !wxFindFirstFile(thesPaths[i] + wxFILE_SEP_PATH + wxT("th*.dat"), wxFILE).IsEmpty())
             return thesPaths[i];
     }
     return thesPaths[0];
@@ -181,9 +181,9 @@
 {
     wxString bitmPath = m_BitmPath;
     Manager::Get()->GetMacrosManager()->ReplaceEnvVars(bitmPath);
-    if (wxFindFirstFile(bitmPath + wxFILE_SEP_PATH + wxT("*.png"), wxFILE).IsEmpty())
-        return m_pPlugin->GetOnlineCheckerConfigPath();
-    return bitmPath;
+    if (wxDirExists(bitmPath) && !wxFindFirstFile(bitmPath + wxFILE_SEP_PATH + wxT("*.png"), wxFILE).IsEmpty())
+        return bitmPath;
+    return m_pPlugin->GetOnlineCheckerConfigPath();
 }
 
 const wxString SpellCheckerConfig::GetRawDictionaryPath()const{return m_DictPath;}

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version