Patch #3271 2012-04-03 20:58
sbezgodov
Select any project or entire workspace to get statistics- Download
- 3271-Select_any_pro.patch (38.9 KB)
Index: codestatexec.h
===================================================================
--- codestatexec.h (revision 8065)
+++ codestatexec.h (working copy)
@@ -15,23 +15,39 @@
#include "language_def.h"
class wxWindow;
+class wxProgressDialog;
/** This class computes the statistics of the project's files and display them.
* @see CodeStat, CodeStatConfigDlg, CodeStatExecDlg, LanguageDef
*/
+
+class CodeStatCache;
+
class CodeStatExecDlg : public wxScrollingDialog
{
- public:
- CodeStatExecDlg(wxWindow* parent) : parent(parent){}
- virtual ~CodeStatExecDlg();
- int Execute(LanguageDef languages[NB_FILETYPES_MAX], int nb_languages);
- private:
- void EndModal(int retCode);
- void CountLines(wxFileName filename, LanguageDef &language,
- long int &code_lines, long int &codecomments_lines,
- long int &comment_lines, long int &empty_lines, long int &total_lines);
- void AnalyseLine(LanguageDef &language, wxString line, bool &comment, bool &code, bool &multi_line_comment);
- wxWindow* parent;
+public:
+ CodeStatExecDlg(wxWindow* parent);
+ virtual ~CodeStatExecDlg();
+ int Execute(LanguageDef languages[NB_FILETYPES_MAX], int nb_languages);
+private:
+ void EndModal(int retCode);
+ void OnSelectProject(wxCommandEvent& evt);
+ void OnIdle(wxIdleEvent& evt);
+ void ParseProject(int index);
+ void DoParseProject(int index);
+ void DoParseWorkspace();
+ void UpdateProgress();
+ void ShowResults(int index);
+
+ wxWindow* m_parent;
+ wxChoice* m_choice;
+ wxProgressDialog* m_progress;
+ CodeStatCache* m_cache;
+ LanguageDef* m_languages;
+ int m_nb_languages;
+ int m_nb_files;
+ int m_current_file;
+ bool m_changed;
};
#endif // CODESTATEXEC_H
Index: resources/main_dialog.xrc
===================================================================
--- resources/main_dialog.xrc (revision 8065)
+++ resources/main_dialog.xrc (working copy)
@@ -1,199 +1,232 @@
<?xml version="1.0" encoding="utf-8" ?>
-<resource xmlns="http://www.wxwidgets.org/wxxrc">
- <object class="wxScrollingDialog" name="dlgCodeStatExec">
- <title>Code Statistics</title>
- <object class="wxBoxSizer">
- <orient>wxVERTICAL</orient>
- <object class="sizeritem">
- <object class="wxStaticBoxSizer">
- <orient>wxVERTICAL</orient>
- <object class="sizeritem">
- <object class="wxGridSizer">
- <cols>2</cols>
- <rows>2</rows>
- <object class="sizeritem">
- <object class="wxStaticText">
- <label>Number of files:</label>
- </object>
- </object>
- <object class="sizeritem">
- <object class="wxStaticText" name="txt_num_files">
- <label>999999</label>
- <style>wxALIGN_RIGHT</style>
- </object>
- <flag>wxALIGN_RIGHT</flag>
- </object>
- <object class="sizeritem">
- <object class="wxStaticText">
- <label>Files skipped:</label>
- </object>
- </object>
- <object class="sizeritem">
- <object class="wxStaticText" name="txt_skipped_files">
- <label>999999</label>
- <style>wxALIGN_RIGHT</style>
- </object>
- <flag>wxALIGN_RIGHT</flag>
- </object>
- <object class="sizeritem">
- <object class="wxStaticText">
- <label>Files not found:</label>
- </object>
- </object>
- <object class="sizeritem">
- <object class="wxStaticText" name="txt_files_not_found">
- <label>999999</label>
- <style>wxALIGN_RIGHT</style>
- </object>
- <flag>wxALIGN_RIGHT</flag>
- </object>
- </object>
- <flag>wxALL|wxEXPAND</flag>
- <border>5</border>
- </object>
- <object class="sizeritem">
- <object class="wxGridSizer">
- <cols>2</cols>
- <rows>2</rows>
- <object class="sizeritem">
- <object class="wxGauge" name="Gauge_Code">
- <range>100</range>
- <size>-1,20</size>
- </object>
- <flag>wxALL|wxEXPAND</flag>
- <border>2</border>
- </object>
- <object class="sizeritem">
- <object class="wxStaticText" name="txt_Gauge_Code">
- <label>XXXX% Code only</label>
- </object>
- <flag>wxALIGN_CENTRE_VERTICAL</flag>
- </object>
- <object class="sizeritem">
- <object class="wxGauge" name="Gauge_Code_Comments">
- <ra
download for full patch...
History
This is CodeStat plugin upgrade.
Just apply the patch. No any sources, configs or images are added.
I'll try this patch and if there are no problem will commit it.
Thank you for the contribution.
Hm, I get an immediate crash, when switching to "Entire workspace". The crash happens, because OnIdle is called twice and m_changed=true, both time. I'm running latest revision of C::B on linux and here is the callstack: #0 0x7fffe0cc21a3 CodeStatExecDlg::DoParseWorkspace(this=0x1a2dd80) (/home/obfuscated/projects/codeblocks/git/src/plugins/contrib/codestat/codestatexec.cpp:251) #1 0x7fffe0cc1b34 CodeStatExecDlg::OnIdle(this=0x1a2dd80, evt=@0x7fffffffb000: <incomplete type>) (/home/obfuscated/projects/codeblocks/git/src/plugins/contrib/codestat/codestatexec.cpp:174) #2 0x7ffff4209e56 wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)() (/usr/lib64/libwx_baseu-2.8.so.0:??) #3 0x7ffff420a23f wxEvtHandler::SearchDynamicEventTable(wxEvent&)() (/usr/lib64/libwx_baseu-2.8.so.0:??) #4 0x7ffff420a2f2 wxEvtHandler::ProcessEvent(wxEvent&)() (/usr/lib64/libwx_baseu-2.8.so.0:??) #5 0x7ffff4908e64 wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #6 0x7ffff4908e34 wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #7 0x7ffff4909365 wxAppBase::ProcessIdle()() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #8 0x7ffff4881f4e ??() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #9 0x7ffff59a6542 g_main_context_dispatch() (/usr/lib64/libglib-2.0.so.0:??) #10 0x7ffff59a6888 ??() (/usr/lib64/libglib-2.0.so.0:??) #11 0x7ffff59a6944 g_main_context_iteration() (/usr/lib64/libglib-2.0.so.0:??) #12 0x7ffff78da2b1 gtk_main_iteration() (/usr/lib64/libgtk-x11-2.0.so.0:??) #13 0x7ffff4882a95 wxApp::Yield(bool)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #14 0x7ffff49a0309 wxProgressDialog::DoAfterUpdate(bool*)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #15 0x7ffff49a0913 wxProgressDialog::Update(int, wxString const&, bool*)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #16 0x7fffe0cc262e CodeStatExecDlg::UpdateProgress(this=0x1a2dd80) (/home/obfuscated/projects/codeblocks/git/src/plugins/contrib/codestat/codestatexec.cpp:291) #17 0x7fffe0cc1e68 CodeStatExecDlg::ParseProject(this=0x1a2dd80, index=3) (/home/obfuscated/projects/codeblocks/git/src/plugins/contrib/codestat/codestatexec.cpp:223) #18 0x7fffe0cc2349 CodeStatExecDlg::DoParseWorkspace(this=0x1a2dd80) (/home/obfuscated/projects/codeblocks/git/src/plugins/contrib/codestat/codestatexec.cpp:266) #19 0x7fffe0cc1b34 CodeStatExecDlg::OnIdle(this=0x1a2dd80, evt=@0x7fffffffb540: <incomplete type>) (/home/obfuscated/projects/codeblocks/git/src/plugins/contrib/codestat/codestatexec.cpp:174) #20 0x7ffff4209e56 wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)() (/usr/lib64/libwx_baseu-2.8.so.0:??) #21 0x7ffff420a23f wxEvtHandler::SearchDynamicEventTable(wxEvent&)() (/usr/lib64/libwx_baseu-2.8.so.0:??) #22 0x7ffff420a2f2 wxEvtHandler::ProcessEvent(wxEvent&)() (/usr/lib64/libwx_baseu-2.8.so.0:??) #23 0x7ffff4908e64 wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #24 0x7ffff4908e34 wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&)() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #25 0x7ffff4909365 wxAppBase::ProcessIdle()() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #26 0x7ffff4881f4e ??() (/usr/lib64/libwx_gtk2u_core-2.8.so.0:??) #27 0x7ffff59a6542 g_main_context_dispatch() (/usr/lib64/libglib-2.0.so.0:??) #28 0x7ffff59a6888 ??() (/usr/lib64/libglib-2.0.so.0:??) #29 0x7ffff59a6c7a g_main_loop_run() (/usr/lib64/libglib-2.0.so.0:??) #30 0x7ffff78da0a7 gtk_main() (/usr/lib64/libgtk-x11-2.0.so.0:??) See how DoParseWorkspace is called twice? I guess moving the m_change=false just after the check if (!m_changed) will fix it. Can you give it a try and post fixed patch?
Hello, I have moved m_changed=false right after check (!m_changed). Now plugin works fine. Tested under linux 32-bit.
Patch is created against trunk 8065 revision.
OK, I've committed your patch. I've made some modifications to make the code a bit clearer and to conform to the cb-style-guide.
Also I've fixed one bug introduced with your patch... see the svn log for details.
Thank you for the contribution.
Now I have to find some time to design a better interface for this plugin.
Have you tought of replacing the current UI with a list ctrl and putting all stats in one page - one line per project and a summary at the bottom?
And would you like to do it as I don't have much time at the moment?