Author Topic: wrap char mode feature added for Editor Tweak plugin  (Read 23387 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5226
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: wrap char mode feature added for Editor Tweak plugin
« Reply #30 on: October 07, 2013, 10:03:24 am »
The reason why I check in a wrong function in rev 9382 is that originally I have code like:
Code: [Select]
cbStyledTextCtrl* EditorTweaks::GetSafeControl()
{
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed || m_isUpdatingUI)
        return nullptr;
    return ed->GetControl();
}

After the testing by dmoore, I quickly blindly remove the m_isUpdatingUI check, thus error happens:
Code: [Select]
cbStyledTextCtrl* EditorTweaks::GetSafeControl()
{
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed)
        return ed->GetControl();
}
;D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: wrap char mode feature added for Editor Tweak plugin
« Reply #31 on: October 07, 2013, 11:08:42 am »
It is generally not safe to call SDK methods if the plugin is not attached (that's what the method IsAttached() is for). So the change in the two places should be fine.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5226
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: wrap char mode feature added for Editor Tweak plugin
« Reply #32 on: October 07, 2013, 11:26:09 am »
It is generally not safe to call SDK methods if the plugin is not attached (that's what the method IsAttached() is for). So the change in the two places should be fine.
I'm curious that this bug should be already in trunk before rev 9382, since I don't change the control sequence in the rev 9382. Do you have a crash call stack? I'm curious which function cause this crash issue. :)

EDIT: I just test rev 9385 (before your fix), I have no crash here.
« Last Edit: October 07, 2013, 12:05:29 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: wrap char mode feature added for Editor Tweak plugin
« Reply #33 on: October 08, 2013, 07:16:47 am »
Do you have a crash call stack? I'm curious which function cause this crash issue. :)
Yes I had one but deleted it already. It was from PluginManager -> RegisterPlugin calling the plugins initialisation routine which caused an updateui event. this caused the illegal method call I had mentioned. Just trust me. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ