Author Topic: CodeStatistics window doesn't really close?  (Read 6158 times)

Offline kkez

  • Almost regular
  • **
  • Posts: 153
    • WinapiZone
CodeStatistics window doesn't really close?
« 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++, 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 :)


Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: CodeStatistics window doesn't really close?
« Reply #1 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.

Offline kkez

  • Almost regular
  • **
  • Posts: 153
    • WinapiZone
Re: CodeStatistics window doesn't really close?
« Reply #2 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.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2877
Re: CodeStatistics window doesn't really close?
« Reply #3 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)
 }


Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: CodeStatistics window doesn't really close?
« Reply #4 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.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: CodeStatistics window doesn't really close?
« Reply #5 on: July 17, 2006, 09:38:38 am »
Quote
I will submit a patch.
and applied ;-)