Author Topic: I found some bug at compilergcc.cpp(patch)  (Read 6111 times)

Offline mmkider

  • Almost regular
  • **
  • Posts: 150
I found some bug at compilergcc.cpp(patch)
« on: November 08, 2008, 05:00:54 am »
Code
Index: compilergcc.cpp
===================================================================
--- compilergcc.cpp (revision 5297)
+++ compilergcc.cpp (working copy)
@@ -1236,7 +1236,7 @@
         // setup dynamic linker path
         wxString newLibPath = GetDynamicLinkerPathForTarget(cmd->target);
         const wxString libPathSep = platform::windows ? _T(";") : _T(":");
- if (!newLibPath.IsEmpty() && newLibPath.SubString(newLibPath.Length() - 1, 1) != libPathSep)
+ if (!newLibPath.IsEmpty() && newLibPath.Mid(newLibPath.Length() - 1, 1) != libPathSep)
  newLibPath << libPathSep;
  newLibPath << oldLibPath;
  wxSetEnv(LIBRARY_ENVVAR, newLibPath);
@@ -1882,7 +1882,7 @@
  const wxString libPathSep = platform::windows ? _T(";") : _T(":");
  libPath << _T(".") << libPathSep;
  libPath << GetStringFromArray(compiler->GetLinkerSearchDirs(target), libPathSep);
- if (!libPath.IsEmpty() && libPath.SubString(libPath.Length() - 1, 1) == libPathSep)
+ if (!libPath.IsEmpty() && libPath.Mid(libPath.Length() - 1, 1) == libPathSep)
  libPath.Truncate(libPath.Length() - 1);
  return libPath;
  }
@@ -3083,7 +3083,7 @@
 {
     wxTreeCtrl* tree = Manager::Get()->GetProjectManager()->GetTree();
     wxTreeItemId sel = tree->GetSelection();
-    FileTreeData* ftd = (FileTreeData*)tree->GetItemData(sel);
+    FileTreeData* ftd=sel.IsOk()?(FileTreeData*)tree->GetItemData(sel):0;
     if (ftd)
     {
         // 'configure' selected target, if other than 'All'


1、
I read some source code, I think that original ideas is that get last word and compare it with libPathSep.
but the paramter of wxString::SubString is begin position with end position, not begin position with length.
libPath.SubString(libPath.Length() - 1, 1) ;//will Over the border

So I replace SubString to Mid, it run fine.

define :

Code
wxString wxString::SubString(size_t from, size_t to) const


 and
Code
wxString wxString::Mid(size_t first, size_t count = wxSTRING_MAXLEN) const






2、 About wxTreeItemId problem(wxTreeItemId  don't always==true)

    If you run codeblocks and open project 、 select "Build Option" Menu , then sel.IsOk==false
    Sometime I will get crash in this problem.
   


Code
FileTreeData* ftd = (FileTreeData*)tree->GetItemData(sel);

to

Code
FileTreeData* ftd=sel.IsOk()?(FileTreeData*)tree->GetItemData(sel):0;



http://mmkider.googlepages.com/compilergccPatch.patch


« Last Edit: November 18, 2008, 02:17:41 am by mmkider »

Offline mmkider

  • Almost regular
  • **
  • Posts: 150
Re: I found some bug at compilergcc.cpp(patch)
« Reply #1 on: November 08, 2008, 03:02:18 pm »
Code

Index: debuggergdb.cpp
===================================================================
--- debuggergdb.cpp (revision 5297)
+++ debuggergdb.cpp (working copy)
@@ -1294,7 +1294,7 @@
             const wxString libPathSep = platform::windows ? _T(";") : _T(":");
             newLibPath << _T(".") << libPathSep;
             newLibPath << GetStringFromArray(actualCompiler->GetLinkerSearchDirs(target), libPathSep);
-            if (newLibPath.SubString(newLibPath.Length() - 1, 1) != libPathSep)
+            if (newLibPath.Mid(newLibPath.Length() - 1, 1) != libPathSep)
                 newLibPath << libPathSep;
             newLibPath << oldLibPath;
             wxSetEnv(LIBRARY_ENVVAR, newLibPath);

the same problem

http://mmkider.googlepages.com/debuggdb.patch