News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

I found some bug at compilergcc.cpp(patch)

Started by mmkider, November 08, 2008, 05:00:54 AM

Previous topic - Next topic

mmkider


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 :

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


and
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.
   


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

to

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



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



mmkider



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