Author Topic: new CC branch built failed  (Read 27605 times)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: rev 5942 CPU usage 50% when an editor is opened.
« Reply #15 on: November 27, 2009, 04:37:07 pm »
I just find a serious bug! SVN rev 5942

when any editor is opened, it seems the the CPU usage was 50%, and the title bar of Code::Blocks gets flashed continuously. :(

Does any one meet the same problem, it seems there is no problem before rev 5939.

I didn't notice any flashing. Tested on Linux. However I'll try to do more testing tomorrow to find any issues with it.


BTW, I didn't track this thread. Rev 5939 was necessary to fix another bug. In OpenFileList plugin, the open file tree shows wrong path of recently opened editor. The bug is noticeable when a file is opened by clicking on project tree. Sending cbEVT_EDITOR_ACTIVATED event fixed that.
Be a part of the solution, not a part of the problem.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: new CC branch built failed
« Reply #16 on: November 27, 2009, 04:39:48 pm »
Just investigated a little deeper:

the BrowseTracker-plugin calls SetActiveEditor in its OnIdle-function (and this one is called quiet often of course).

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: new CC branch built failed
« Reply #17 on: November 27, 2009, 04:40:41 pm »
I can confirm this (on linux).
I have a small plugin, that hooks into C::B event-sink to debug C::B's internal events, and we get flooded with cbEVT_EDITOR_ACTIVATED.
Removing Biplabs commit from svn r5939 fixed this issue.

It was not sent before and thus it's usual that you get a number of such events after that change was made.

Nevertheless, I'll test it more tomorrow and revert the commit if that's necessary.
Be a part of the solution, not a part of the problem.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: new CC branch built failed
« Reply #18 on: November 27, 2009, 04:42:30 pm »
Just investigated a little deeper:

the BrowseTracker-plugin calls SetActiveEditor in its OnIdle-function (and this one is called quiet often of course).

Thanks for the quick update. IMO, code in BrowseTracker plugin should be changed. OnIdle function will be called frequently resulting in flooding of such event.
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: new CC branch built failed
« Reply #19 on: November 27, 2009, 04:48:47 pm »
IMO, code in BrowseTracker plugin should be changed. OnIdle function will be called frequently resulting in flooding of such event.

Agreed :D

Code
void BrowseTracker::OnIdle(wxIdleEvent& event)
// ----------------------------------------------------------------------------
{
     event.Skip();

    // Focus the new selected editor. This doesn't work if a long compile
    // is active since there's no idle time. User will have to click into
    // the editor window to activate it.
    // This used to be done by the CB editor manager, but someone removed the UI hook.
    if ((not Manager::Get()->IsAppShuttingDown()) && m_UpdateUIFocusEditor)
    {
        if (m_UpdateUIFocusEditor)
        {
            EditorBase* eb = m_UpdateUIFocusEditor;
            if (not eb) return;
            m_UpdateUIFocusEditor = 0;
            Manager::Get()->GetEditorManager()->SetActiveEditor(eb);
             eb->SetFocus();
            #if defined(LOGGING)
             LOGIT( _T("BT OnIdle Focused Editor[%p] Title[%s]"), eb, eb->GetTitle().c_str() );
            #endif
            // re-sort the browse marks
            wxCommandEvent ev;
            OnMenuSortBrowse_Marks(ev);
        }
    }
}

Note:

Quote
// This used to be done by the CB editor manager, but someone removed the UI hook.
: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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: new CC branch built failed
« Reply #20 on: November 27, 2009, 05:23:15 pm »
IMO, code in BrowseTracker plugin should be changed. OnIdle function will be called frequently resulting in flooding of such event.

Agreed :D

Code
void BrowseTracker::OnIdle(wxIdleEvent& event)
// ----------------------------------------------------------------------------
{
     event.Skip();

    // Focus the new selected editor. This doesn't work if a long compile
    // is active since there's no idle time. User will have to click into
    // the editor window to activate it.
    // This used to be done by the CB editor manager, but someone removed the UI hook.
    if ((not Manager::Get()->IsAppShuttingDown()) && m_UpdateUIFocusEditor)
    {
        if (m_UpdateUIFocusEditor)
        {
            EditorBase* eb = m_UpdateUIFocusEditor;
            if (not eb) return;
            m_UpdateUIFocusEditor = 0;
            Manager::Get()->GetEditorManager()->SetActiveEditor(eb);
             eb->SetFocus();
            #if defined(LOGGING)
             LOGIT( _T("BT OnIdle Focused Editor[%p] Title[%s]"), eb, eb->GetTitle().c_str() );
            #endif
            // re-sort the browse marks
            wxCommandEvent ev;
            OnMenuSortBrowse_Marks(ev);
        }
    }
}

Note:

Quote
// This used to be done by the CB editor manager, but someone removed the UI hook.
:D


To fix this issue and be able to still use BrowseTracker, you can add :
Code
if(Manager::Get()->GetEditorManager()->GetActiveEditor() != eb)
before
Code
Manager::Get()->GetEditorManager()->SetActiveEditor(eb);
in BrowseTracker's OnIdle.

It's maybe only a workaround and I think pecan should look into this code, whether it is still needed or not, so I do not commit it to trunk.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: new CC branch built failed
« Reply #21 on: November 28, 2009, 07:05:34 am »
To fix this issue and be able to still use BrowseTracker, you can add :
Code
if(Manager::Get()->GetEditorManager()->GetActiveEditor() != eb)
before
Code
Manager::Get()->GetEditorManager()->SetActiveEditor(eb);
in BrowseTracker's OnIdle.

It's maybe only a workaround and I think pecan should look into this code, whether it is still needed or not, so I do not commit it to trunk.

Thanks jens!!! You are so smart!

Where is pecan? :D

Also, I just modify to this. (include " eb->SetFocus(); " to the if statement), also works.

Code
// ----------------------------------------------------------------------------
void BrowseTracker::OnIdle(wxIdleEvent& event)
// ----------------------------------------------------------------------------
{
     event.Skip();

    // Focus the new selected editor. This doesn't work if a long compile
    // is active since there's no idle time. User will have to click into
    // the editor window to activate it.
    // This used to be done by the CB editor manager, but someone removed the UI hook.
    if ((not Manager::Get()->IsAppShuttingDown()) && m_UpdateUIFocusEditor)
    {
        if (m_UpdateUIFocusEditor)
        {
            EditorBase* eb = m_UpdateUIFocusEditor;
            if (not eb) return;
            m_UpdateUIFocusEditor = 0;
            if(Manager::Get()->GetEditorManager()->GetActiveEditor() != eb)
            {
                Manager::Get()->GetEditorManager()->SetActiveEditor(eb);
                eb->SetFocus();
            }

            #if defined(LOGGING)
             LOGIT( _T("BT OnIdle Focused Editor[%p] Title[%s]"), eb, eb->GetTitle().c_str() );
            #endif
            // re-sort the browse marks
            wxCommandEvent ev;
            OnMenuSortBrowse_Marks(ev);
        }
    }
}
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 Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: new CC branch built failed
« Reply #22 on: November 30, 2009, 03:37:00 pm »
EDIT: BrowseTracker fixed svn 5944

Acknowledging this thread. I'll look into the situations.

thanks,
pecan
« Last Edit: November 30, 2009, 05:04:50 pm by Pecan »