Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

I found some bug at compilergcc.cpp(patch)

(1/1)

mmkider:

--- 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'


--- End code ---

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
--- End code ---


 and

--- Code: ---wxString wxString::Mid(size_t first, size_t count = wxSTRING_MAXLEN) const
--- End code ---






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);
--- End code ---

to


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



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


mmkider:

--- 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);

--- End code ---

the same problem

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

Navigation

[0] Message Index

Go to full version