News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Endless stream of events - CB-16.01

Started by ridge, January 25, 2017, 12:57:24 AM

Previous topic - Next topic

ridge

I inserted DebugLog statements in main.cpp right before event.Skip() in each handler (e.g., OnEditMenuUpdateUI, OnViewMenuUpdateUI, OnSearchMenuUpdateUI).  Then, built and ran CB.  There appears to be an unexpected endless stream of events even when there is no UI activity.

OnEditMenuUpdateUI called
OnEditMenuUpdateUI called
OnEditMenuUpdateUI called
.
.
.
Is this expected?

oBFusCATed

Don't know. Have you tried to place a breakpoint to see what triggers the events?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

This is by design, because we update the menu item status in a single function, this function is called about 500ms(maybe another value, but I can't remember for now) at a time.
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.

yvesdm3000

Quote from: ollydbg on January 25, 2017, 02:47:03 PM
This is by design, because we update the menu item status in a single function, this function is called about 500ms(maybe another value, but I can't remember for now) at a time.
Shouldn't this happen when the menu is clicked e.g. opened ?

Yves
Clang based code completion for Code::Blocks:   [url="http://github.com/yvesdm3000/ClangLib"]http://github.com/yvesdm3000/ClangLib[/url]

ollydbg

#4
Quote from: yvesdm3000 on January 25, 2017, 03:18:30 PM
Quote from: ollydbg on January 25, 2017, 02:47:03 PM
This is by design, because we update the menu item status in a single function, this function is called about 500ms(maybe another value, but I can't remember for now) at a time.
Shouldn't this happen when the menu is clicked e.g. opened ?

Yves
It should. But as far as I know, there are too many menu items and to many menu status, so we have some alternative way to update the menu status, see discussions here: wxUpdateUIEvent performance issues

EDIT: I just see in the source code, we have 100ms setting values.
MainFrame* CodeBlocksApp::InitFrame()
{
    static_assert(wxMinimumVersion<2,8,12>::eval, "wxWidgets 2.8.12 is required");

    MainFrame *frame = new MainFrame();
    wxUpdateUIEvent::SetUpdateInterval(100);
    SetTopWindow(nullptr);

    if (g_DDEServer && m_DDE)
        g_DDEServer->SetFrame(frame); // Set m_Frame in DDE-Server

    return frame;
}
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.

ridge

#5
This is important information - thanks for the link.
It hasn't been discussed since 2009??
I think Jens' comments are worth noting - perhaps we should take heed in the release version?

1. Bind only one ID to the appropriate OnxxxMenuUpdateUI-function.
2. Set the update-interval to 500 ms (or 200 ms?).

What do you think?
I'd like to understand why we're binding all of the events - there must be a good reason - anybody know?

oBFusCATed

Lets start with: What is the real problem?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ridge

#7
Good question.  My original post was a request for information (which I got).
I'm trying to figure out why wxChoice items don't show up on custom toolbars in CodeBlocks
(at least on MacOS).  As I began debugging, it was unexpected to receive so many events
(which seemed unnecessary) so I thought I'd ask.

I suppose the problem is that I don't have a design document for CodeBlocks.

oBFusCATed

There is no such thing as design document. Use the code svn blame/git blame are your best friends.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]