Menu

quit message

2007-10-05
2012-11-14
  • Damjan Cvetko

    Damjan Cvetko - 2007-10-05

    Hello Don.

    I could really use a "quit" message. Something plugins would get just before N++ destroys the main window.
    I could use this to close and destroy child windows.

    Best regards.
    -Z

     
    • Don HO

      Don HO - 2007-10-06

      I don't understand you.

      Don

       
      • Damjan Cvetko

        Damjan Cvetko - 2007-10-12

        Hi Don.

        I made a patch to demonstrate what I wanted to say. I also tested this and it seems to solve the problems I'm having with my plugin.

        Best regards.
        -Zobo

        Index: Notepad_plus.cpp

        --- Notepad_plus.cpp    (revision 50)
        +++ Notepad_plus.cpp    (working copy)
        @@ -6636,6 +6636,9 @@
                     if (nppgui._rememberLastSession)
                         getCurrentOpenedFiles(currentSession);

        +            // Send WM_CLOSE to all plugins -Zobo
        +            _pluginsManager.relayNppMessages(WM_CLOSE, 0, 0);
        +
                     if (fileCloseAll())
                     {
                         _lastRecentFileList.saveLRFL();

         
        • Don HO

          Don HO - 2007-10-12

          I don't think this message is really necessary.

          When Notepad++ is lanched, it loads the plugins by calling LoadLibary,
          so the plugins should do the initialization with the message DLL_PROCESS_ATTACH in DLLMain.
          When Notepad++ quit, it frees all the dlls it loaded by calling FreeLibary(),
          so the plugins should do their clean up in the message DLL_PROCESS_DETACH in DLLMain.

          I did answer Harry for his FTP_Synchronize crash issue here :
          https://sourceforge.net/forum/message.php?msg_id=4513511

          Don

           
          • Damjan Cvetko

            Damjan Cvetko - 2007-10-13

            Hi Don, thanks for your answer.

            I am already using the _ATTACH and _DETACH routines to perform initialization and deinitialization.
            I had a quick look at the suggestion from the other (FTP) forum thread, but I think that my problem lies more in the fact that when DLL_PROCESS_DETACH happens, the main window is already freed and NppData.NppHandle is invalid, than in problems with threads.
            That's why I suggest that WM_CLOSE message be relayed to plugins before ::DestroyWindow. However It would perhaps be better if it was moved down after fileCloseAll() returns true. (Note, when my plugin gets WM_CLOSE it only closes all plugin windows, but stays fully functional as a plugin. All other data gets freed as DLL_PROCESS_DETACH phase.)
            With a few other modifications this kind of messages could be used to query plugins if they are willing to exit. Think of the situation I have: "PHP debugging session in progress, really quit?"

            I will still try to locate the source of the locking problem, but please consider this proposal. If NPP gives any other hint that it's going to shut down before its main window handle is freed, please let me know.

            If you want to see what happens, you only need to put dbgpplugin.dll into plugins directory, start NPP, open the debugger (Plugins/DBGp/Debugger) and exit NPP. To increase the chance of a lockup, try to undock some of the dialogs (stack, breakpoints, context...). The main window of NPP will close, but the Notepad++.exe process will stay.

            Thanks again, best regards.
            -Zobo

             
            • Don HO

              Don HO - 2007-10-13

              OK, I see the problem.

              The notification message NPPN_SHOUTDOWN will be added in Notepad++ v4.4

              Don

               
              • Damjan Cvetko

                Damjan Cvetko - 2007-10-14

                Thanks, this helps a lot.
                I'll check it out when it gets to SVN.

                Best,
                -Zobo

                 
    • Harry

      Harry - 2007-10-06

      Before calling FreeLibrary, send a notification message to the plugin like NPPN_SHUTDOWN so cleanup can be done. Although destroying child windows isnt really neccessary I think (notepad is destroyed before the plugin if im correct, thus destroying all child windows), I do would like such a feature so all threads can safely be stopped, among other things. When a DLL is detaching all of its threads cannot properly detach from it because its in the DllMain function, which has been serialized
      (http://blogs.msdn.com/oldnewthing/archive/2007/09/04/4731478.aspx , last paragraph).

       
      • Damjan Cvetko

        Damjan Cvetko - 2007-10-06

        Thank you for translating my "greek".
        Yes, I'd need something like this, because my plugin sometimes prevents Notepad++ from shutting down correctly. The window is gone, but the process lingers and eats up all CPU.

        Thanks.
        -Z

         
MongoDB Logo MongoDB