1. Aleš Vojáček
  2. PowerBuilder
  3. Thursday, 20 October 2022 14:28 PM UTC

Hi all,

I need to do some cleanup just before application ends.

Which of these events are ok for that?

I will exist application using menu/exit it will fire pfc_exit but no pfc_close.

When I close application usig close mdi_frame x then it will fire pfc_close, but no pfc_exit.

I tried to find some info about correct life time of pfc application but did not find any.

Is it ok to fire pfc_exit from pfc_close (events from gnv_app instance)

Thank you Ales

 

EDIT>

The problem was, because I tried to find one place for some cleaning and auditing when app ends (by different type of ending).

I had break points to find that place.

Powerbuilder IDE while debugging did not stop at one place if i closed application by clickink exit in menu (then it stops in pfc_exit event of gnv_app) but did not stop in pfc_close event.  When I try to close app using Alt+F4 then debugger did not stop in any place (pfc_exit, pfc_close nor in destructor of gnv_app)

After hours of debugging and trying I restarted PB and then it stops in pfc_close every time and every type of closing app. So that the problem was some strange behaviour of PB Debugger :-(

Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 15:40 PM UTC
  2. PowerBuilder
  3. # 1

What was the solution?

 

Comment
  1. Aleš Vojáček
  2. Thursday, 20 October 2022 15:45 PM UTC
The solution is restart of PB IDE (2021 1509). The debugger then started to stop in events on breakpoints and everything started to make sense.

gnv_app.pfc_exit is called from menu/exit it can do some processing after menu exit but pfc_exit is not called when w_frame or application is closed by alt+f4 or close icon on window

gnv_app.pfc_close on the other way is called regardless of type of ending application (from menu, alt+f4, close icon on window) so place for me wich is called every time when application closes is pfc_close on gnv_app .
  1. Helpful 1
  1. Tracy Lamb
  2. Thursday, 20 October 2022 16:01 PM UTC
Thank you. Didn't notice that your original post was the solution.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 15:07 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Ales -

In our commercial PFC-based application, we have the following code in the Application object's Close event:

gnv_app.event pfc_close()
destroy gnv_app

This ensures the application manager's pfc_close event always fires when the app closes. We perform cleanup tasks in this event and in the application manager's destructor event.

Best regards, John

Comment
  1. Aleš Vojáček
  2. Thursday, 20 October 2022 15:18 PM UTC
Hi,

I have same setup.

But if I close application using x icon in window title bar (no menu Exit, toolbar Exit) but simply close window with x icon or with alt+f4 . Then evets pfc_close either pfc_exit nor destructor of gnv_app are not fired :-(

  1. Helpful
  1. Aleš Vojáček
  2. Thursday, 20 October 2022 15:19 PM UTC
So there is some strange behaviour.

After restart of PowerBuilder, now debbuger stops in those events :-(

That is strange.

A.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 14:42 PM UTC
  2. PowerBuilder
  3. # 3

Hi.

It's not clear to me what sort of cleanup you want to do. But I wonder if n_cst_appmanager (gnv_app) destructor event would be a good place.

Andreas.

Comment
  1. Aleš Vojáček
  2. Thursday, 20 October 2022 15:05 PM UTC
Hi,

I need to write about application ending into DB audit table.

So I need one place which is called in any type of appending.

But in some situations is pfc_exit called and sometimes pfc_close is called sometimes either of them.

I hoped that pfc_close is one which is called after pfc_exit but that is not that case.

So I hoped, that there is somewhere default/recommended event flow of pfc application, but I found none :-(
  1. Helpful
  1. Aleš Vojáček
  2. Thursday, 20 October 2022 15:07 PM UTC
The strange thing is that if I close application with x icon (close icon int window title bar) then either pfc_close or pfc_exit (of gnv_app) is called.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.