Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

UpdateUI Events Not Exactly the problem

(1/3) > >>

devilsclaw:
Im currently running a Linux From Scratch Based System I compiled and its running wx 2.6.3
and gcc 4.0.3

I was reading around about possible reasons for the image list stuff since I thought it erroring might of been the cause of the slow down.

In one of the post it said the UpdateUI needed cleaned up, so I commented out all the events in the src/src/main.cpp and slowly uncommented sections.
like I thought it only hit a massive slow down when the plugins events were added. so I figured it must be one of the plugins.

with all the events back on I went into the plugin manager and disabled a couple and when I got to the compiler which is right now 0.99
everything stopped lagging up. re-enabled all the other plugins and still no lag re-enabled compiler lag back dissabled lag gone..

from what I can tell is the compiler is the only one that adds its own tool bars and im guessing it has its own events that might lap over the main windows events or something like that.
and when one updates its self the other does and it keeps looping.

This is only a guess right now on the possible cause of the two reacting to each other. im going to dig deeper.

Edit: I found the source of the massive slow downs and cpu peeks.. not sure what to do with it right now though.
in file: src/plugins/compilergcc.cpp

the events that have to do with menu handling if any are added they add a little bit of slow down certain ones add more then others but if you have a good set of them on
you get the massive slow down.


Edit2:

--- Code: ---     EVT_UPDATE_UI(idMenuCompile, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCompileTarget, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCompileFromProjectManager, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuProjectCompilerOptions, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuTargetCompilerOptions, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuTargetCompilerOptionsSub, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCompileFile, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCompileFileFromProjectManager, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuRebuild, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuRebuildTarget, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuRebuildFromProjectManager, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCompileAll, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuRebuildAll, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuClean, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCleanAll, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCleanTarget, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCleanFromProjectManager, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuCompileAndRun, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuRun, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuKillProcess, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuSelectTarget, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuNextError, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuPreviousError, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuClearErrors, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuExportMakefile, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idMenuSettings, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idToolTarget, CompilerGCC::OnUpdateUI)
     EVT_UPDATE_UI(idToolTargetLabel, CompilerGCC::OnUpdateUI)

--- End code ---

as you will notice all of these point to CompilerGCC::OnUpdateUI

when i commented out all of this function except the skip event and turned back on all the events the system had no cpu spikes.. so this is most likely where
the trimming needs done.. or some function that is used inside of this is using to many cycles like the project code or something.. will dig deeper.

Edit3: I found the exact line causing the problem now.

line: 3114
in file: src/plugins/compilergcc.cpp

--- Code: ---3113        // Project menu
3114        mbar->Enable(idMenuProjectCompilerOptions, !running && prj);

--- End code ---

if you comment this out the program has no real cpu spikes. since im running dual core system it only spikes up to 60% but if i had a single core it would be 100%

since im new to this code im not exactly sure why this one line causes the problem but I know it does. I would love if someone could tell me.
but if they cant I will look into it more.

btw if i didnt mention it yet the svn is 3780

on a side not if you actually click build options, i waited about two minutes and the dialog finally poped up. the about another 30 seconds and the option screen was finally showing.

in the current state the option screen is useless since you are not ever really able to select any options. or anything.

for testing i tryed both with the code as i pointed out being the problem commented and un commented and same results..
build options is broken at least if i have a project or not. side not the project was a empty type not sure if this matters.

byo:
Hmm, I'm just curious what will be the result, could you try the following code ? :

--- Code: ---if ( mbar->IsEnabled(idMenuProjectCompilerOptions) != ( !running && prj ) )
{
    mbar->Enable(idMenuProjectCompilerOptions, !running && prj);
}

--- End code ---

BYO

mandrav:
Please go on rambling, you will soon fix all remaining bugs :lol:
That's the reason I 'm not responding in this topic: you 're doing fine on your own ;).

Good job :mrgreen:

stahta01:
Here's the code I use to make patches.


--- Code: ---SET PATH=C:\Program Files\Subversion\bin
svn.exe diff --extensions --unified --extensions --ignore-eol-style > filename-unix.patch
PAUSE

--- End code ---

Here's the command I apply the patch with

--- Code: ---unix2dos --newfile filename-unix.patch filename.patch
patch --backup-if-mismatch --unified --strip=0 --ignore-whitespace --forward --input=filename.patch

--- End code ---


--- Quote ---Note: I am using the "patch" command from UnxUtils from
http://sourceforge.net/projects/unxutils

Note: I am using the "unix2dos" command from MinGW
http://sourceforge.net/projects/mingw/
http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82721&release_id=158859
(mingw-utils-0.3)

--- End quote ---

Here's you patch formatted that way.


--- Code: ---Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 3790)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -521,6 +521,8 @@
     if (!CheckProject())
         return;
 
+    cbProject* prj = Manager::Get()->GetProjectManager()->GetActiveProject();
+    bool running = IsRunning();
     if (!data || data->GetKind() == FileTreeData::ftdkUndefined)
     {
         // popup menu in empty space in ProjectManager
@@ -536,6 +538,10 @@
         menu->Append(idMenuCleanFromProjectManager, _("Clean"));
         menu->AppendSeparator();
         menu->Append(idMenuProjectCompilerOptions, _("Build options"));
+        menu->Enable(idMenuCompileFromProjectManager, !running && prj);
+        menu->Enable(idMenuRebuildFromProjectManager, !running && prj);
+        menu->Enable(idMenuCleanFromProjectManager, !running && prj);
+        menu->Enable(idMenuProjectCompilerOptions, !running && prj);
     }
     else if (data && data->GetKind() == FileTreeData::ftdkFile)
     {
@@ -545,6 +551,7 @@
             // popup menu on a compilable file
             menu->AppendSeparator();
             menu->Append(idMenuCompileFileFromProjectManager, _("Build file"));
+            menu->Enable(idMenuCompileFileFromProjectManager, !running && prj);
         }
     }
 }
@@ -3090,15 +3097,11 @@
     {
         mbar->Enable(idMenuCompile, !running && (prj || ed));
         mbar->Enable(idMenuCompileAll, !running && prj);
-//        mbar->Enable(idMenuCompileFromProjectManager, !running && prj);
         mbar->Enable(idMenuCompileFile, !running && ed);
-//        mbar->Enable(idMenuCompileFileFromProjectManager, !running && prj);
         mbar->Enable(idMenuRebuild, !running && prj);
         mbar->Enable(idMenuRebuildAll, !running && prj);
-//        mbar->Enable(idMenuRebuildFromProjectManager, !running && prj);
         mbar->Enable(idMenuClean, !running && prj);
         mbar->Enable(idMenuCleanAll, !running && prj);
-//        mbar->Enable(idMenuCleanFromProjectManager, !running && prj);
         mbar->Enable(idMenuCompileAndRun, !running && (prj || ed));
         mbar->Enable(idMenuRun, !running && (prj || ed));
         mbar->Enable(idMenuKillProcess, running);
@@ -3109,9 +3112,6 @@
 //        mbar->Enable(idMenuClearErrors, cnt);
 
         mbar->Enable(idMenuExportMakefile, false);// !running && prj);
-
-        // Project menu
-        mbar->Enable(idMenuProjectCompilerOptions, !running && prj);
     }
 
     // enable/disable compiler toolbar buttons

--- End code ---

Biplab:
I'm afraid to say that the patch is not of much relevance.


--- Code: ---Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 3790)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -536,6 +538,10 @@
         menu->Append(idMenuCleanFromProjectManager, _("Clean"));
         menu->AppendSeparator();
         menu->Append(idMenuProjectCompilerOptions, _("Build options"));
+        menu->Enable(idMenuCompileFromProjectManager, !running && prj);
+        menu->Enable(idMenuRebuildFromProjectManager, !running && prj);
+        menu->Enable(idMenuCleanFromProjectManager, !running && prj);
+        menu->Enable(idMenuProjectCompilerOptions, !running && prj);
     }
     else if (data && data->GetKind() == FileTreeData::ftdkFile)
     {

--- End code ---

If a project is running, then pop-up menus, mentioned in line 536,6 +538,10 are not created at all. So there is no point of disabling them. Look at the following code in plugins/compilergcc/compilergcc.cpp:519


--- Code: ---    if (type != mtProjectManager || !menu || IsRunning())
        return;
--- End code ---

So if a project is running, the menu at Project Manager is Not created.

idMenuProjectCompilerOptions denotes the menu id of Build options in Project menu and idMenuProjectCompilerOptionsFromProjectManager represents menu option in Project Manager. So if you apply the following patch, then basically you are disabling updating of Project menu when a project is being built. The same convention is followed for other menu items, too.


--- Code: ---Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 3790)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -3109,9 +3112,6 @@
 //        mbar->Enable(idMenuClearErrors, cnt);
 
         mbar->Enable(idMenuExportMakefile, false);// !running && prj);
-
-        // Project menu
-        mbar->Enable(idMenuProjectCompilerOptions, !running && prj);
     }

--- End code ---

There were couple of typos in that file, which I've fixed in the latest revision. I'm not posting the patch which you can see at the following link.

--- Quote ---http://svn.berlios.de/viewcvs/codeblocks?rev=3791&view=rev
--- End quote ---

Regards,

Biplab

Navigation

[0] Message Index

[#] Next page

Go to full version