Menu

#106 fix for 2 simple assertions

Next_Nightly
fixed
ollydbg
Patch
2016-01-30
2014-12-05
No

I am using the latest codeblocks and WX_3_0_BRANCH, compiling everything with debugging on (I think that this makes the code more picky). When I do this, I get 2 reproducible assertions:

  1. type #include< in an edit window
    You'll get an assertion as the code tries get the "last" character of an empty string. This fix is very obvious.

  2. call a function and type some args. Something like fn(a,b,c,d)
    You'll get an assertion. There may be a better fix here. AFAIK the code is just pedantically failing because its expecting a long int but getting just an int. Yes, it may be a wx error because I thought %d should be int... regardless, explicit casting seems to fix:

Index: debian/changelog
===================================================================
--- debian/changelog    (revision 10036)
+++ debian/changelog    (working copy)
@@ -1,4 +1,4 @@
-codeblocks (13.12svn9513) unstable; urgency=low
+codeblocks (13.12svn10036) unstable; urgency=low

   * New svn revision

Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp   (revision 10036)
+++ src/plugins/codecompletion/codecompletion.cpp   (working copy)
@@ -1146,8 +1146,11 @@
     // which has the prefix "abc"
     wxString filename = line.SubString(keyPos, tknEnd - lineStartPos - 1);
     filename.Replace(wxT("\\"), wxT("/"), true);
-    if (filename.Last() == wxT('"') || filename.Last() == wxT('>'))
+    if (!filename.empty())
+      {
+      if (filename.Last() == wxT('"') || filename.Last() == wxT('>'))
         filename.RemoveLast();
+      }

     size_t maxFiles = m_CCMaxMatches;
     if (filename.IsEmpty() && maxFiles > 3000)
Index: src/sdk/ccmanager.cpp
===================================================================
--- src/sdk/ccmanager.cpp   (revision 10036)
+++ src/sdk/ccmanager.cpp   (working copy)
@@ -1102,7 +1102,7 @@
             tips.front().Prepend(wxT("\001\002")); // up/down arrows
             ++offset;
         }
-        tips.push_back(wxString::Format(wxT("(%d/%u)"), m_CurCallTip - m_CallTips.begin() + 1, m_CallTips.size()));
+        tips.push_back(wxString::Format(wxT("(%ld/%lu)"), (long int) (m_CurCallTip - m_CallTips.begin() + 1), (long unsigned int) (m_CallTips.size())));
         // store for better first choice later
         m_CallTipChoiceDict[CCManagerHelper::CallTipToInt(m_CallTips.front().tip, m_CallTips.size())] = m_CurCallTip - m_CallTips.begin();
         // fuzzy store

Discussion

  • ollydbg

    ollydbg - 2014-12-07
    • labels: --> CodeCompletion
     
  • Morten MacFly

    Morten MacFly - 2015-02-07
    • Type: --> Undefined
     
  • Alpha

    Alpha - 2015-02-07
    • Type: Undefined --> Patch
     
  • ollydbg

    ollydbg - 2015-09-08
    • assigned_to: ollydbg
     
  • ollydbg

    ollydbg - 2015-09-08

    I don't have C::B with wx3, but look at the patch file, I think both are obvious fix. Thanks, I will apply it in a few days.

     
  • ollydbg

    ollydbg - 2015-10-06

    The first part of the patch is already fixed in the trunk:

    Revision: 75161a7ca3c6421761effa04689bc763ef744d2f
    Author: fuscated <fuscated@2a5c6006-c6dd-42ca-98ab-0921f2732cef>
    Date: 2015-6-4 7:03:33
    Message:
    - wx3: Fix assert in the code that shows the include file completion
    
    git-svn-id: https://svn.code.sf.net/p/codeblocks/code/trunk@10320 2a5c6006-c6dd-42ca-98ab-0921f2732cef
    ----
    Modified: src/plugins/codecompletion/codecompletion.cpp
    
     

    Last edit: ollydbg 2015-10-06
  • ollydbg

    ollydbg - 2015-10-06

    The second part of the patch is also fixed in the commit:

    Revision: a736adcdca5d4f8b6b5be136be6dfcaf6216c03d
    Author: fuscated <fuscated@2a5c6006-c6dd-42ca-98ab-0921f2732cef>
    Date: 2015-6-23 6:47:13
    Message:
    - wx3: Fix assertion because of wrong types passed to the printf like wxString::Format
    
    git-svn-id: https://svn.code.sf.net/p/codeblocks/code/trunk@10343 2a5c6006-c6dd-42ca-98ab-0921f2732cef
    ----
    Modified: src/sdk/ccmanager.cpp
    

    Which use the operator<< method.

     
  • ollydbg

    ollydbg - 2015-10-06

    So, I close this ticket, and sorry for the late response. Thanks for the contribution.

     
  • ollydbg

    ollydbg - 2015-10-06
    • status: open --> fixed
     
  • Teodor Petrov

    Teodor Petrov - 2015-10-06
    • labels: CodeCompletion --> CodeCompletion, wx30
     

Log in to post a comment.