Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: kkez on July 15, 2006, 10:42:59 pm

Title: CodeStatistics window doesn't really close?
Post by: kkez on July 15, 2006, 10:42:59 pm
There's a problem with the CodeStats window. If you execute this plugin one or two times and then look at a list of open windows like the one you can get using winspy++ (http://www.catch22.net/software/winspy.asp), you'll see that it's still open, but invisible and no longer "modal".
It should be a problem with the dialog not being modal when created, and the use of EndModal when you close it. I'm not familiar with wxwidgets so i don't know what to use instead of EndModal :)

(http://img301.imageshack.us/img301/3876/codestatsnx7.th.png) (http://img301.imageshack.us/my.php?image=codestatsnx7.png)
Title: Re: CodeStatistics window doesn't really close?
Post by: Game_Ender on July 15, 2006, 10:53:20 pm
By default when you create no modal dialogs in wxWidgets clicking the close button or hitting ok/cancel only hides them.  This lets you reshow them without having to recreate them every time.  You should be able to capture the close event or the click event and destroy the dialog.
Title: Re: CodeStatistics window doesn't really close?
Post by: kkez on July 16, 2006, 04:28:30 pm
This lets you reshow them without having to recreate them every time.
But the point is that CodeStats keeps creating new windows without destroying or reusing them.
Title: Re: CodeStatistics window doesn't really close?
Post by: Pecan on July 16, 2006, 06:07:44 pm
This lets you reshow them without having to recreate them every time.
But the point is that CodeStats keeps creating new windows without destroying or reusing them.


Yes, you are right. CodeStat is missing a dlg->Destroy() after it's EndModal();
I will submit a patch.

Thanks
pecan

If you want to fix it yourself, here's a patch
Code
Index: codestat.cpp
===================================================================
--- codestat.cpp (revision 2750)
+++ codestat.cpp (working copy)
@@ -100,13 +100,14 @@
  return -1;
  }
 
+    int dlgReturnCode = 0; //(pecan 2006/7/16)
     dlg = new CodeStatExecDlg(Manager::Get()->GetAppWindow());
 
     // Load the language settings and launch the main function
     LanguageDef languages[NB_FILETYPES_MAX];
     int nb_languages = LoadSettings(languages);
     if(dlg->Execute(languages,nb_languages) != 0)
-        return -1;
-
-    return 0;
+        dlgReturnCode = -1; //(pecan 2006/7/16)
+    dlg->Destroy();         //(pecan 2006/7/16)
+    return dlgReturnCode;   //(pecan 2006/7/16)
 }

Title: Re: CodeStatistics window doesn't really close?
Post by: Game_Ender on July 16, 2006, 06:19:08 pm
You should be able to capture the close event or the click event and destroy the dialog.

That was the key line to my post.
Title: Re: CodeStatistics window doesn't really close?
Post by: killerbot on July 17, 2006, 09:38:38 am
Quote
I will submit a patch.
and applied ;-)