Issue with document closing event chain
Posted: Thu Jan 11, 2018 9:05 am
Hello Tracker-Team,
We have a situation where I have 2 tabs open in a custom control, and then attempt to close one of them (via the "x" button on the tab). However, when I look at what events are triggered by this action in the "PdfCtl_OnEvent" function, I see the following chain:
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65537
pdfCtl.OnEvent: EventID==2420 / EventDisplayName==e.document.modStateChanged / CoreDoc.ID==65537
pdfCtl.OnEvent: EventID==2397 / EventDisplayName==e.document.activated / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2389 / EventDisplayName==e.activeDocChanged / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2399 / EventDisplayName==e.document.closed / CoreDoc.ID==65542
As you can see, the "beforeclosed" event for document 65537 is triggered, but not the "closed" event. Strangely, a "closed" event is later triggered - however, this is for document 65542, which remains open in the control. It is worth noting that this behaviour occurs regardless of whether the tab being closed is the active tab or not. This is causing us problems, as we are not able to correctly communicate with our back-end system which document(s) have been edited and/or closed.
This problem gets worse when we attempt to close all open tabs simultaneously. To illustrate this problem, I opened 3 documents in the control, and then closed the main form of my application. Here is the output I received from the "PdfCtl_OnEvent" function:
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65545
pdfCtl.OnEvent: EventID==2420 / EventDisplayName==e.document.modStateChanged / CoreDoc.ID==65545
pdfCtl.OnEvent: EventID==2397 / EventDisplayName==e.document.activated / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2389 / EventDisplayName==e.activeDocChanged / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2399 / EventDisplayName==e.document.closed / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2397 / EventDisplayName==e.document.activated / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2389 / EventDisplayName==e.activeDocChanged / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2399 / EventDisplayName==e.document.closed / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65542
Again, the "closed" event is not triggered for the first document. However, in this case the "closed" event IS then triggered for the remaining 2 documents. However, for these documents the "beforeclosed" event is triggered AFTER the "closed" event. We are also finding that after this output is generated, we receive a System.NullReferenceException when trying to access the "pdfCtl.Doc.CoreDoc.ID" property (also in the "PdfCtl_OnEvent" function).
I am unsure why this is happening... Should you require any further details to help get to the bottom of this, please do let me know!
// Martin
We have a situation where I have 2 tabs open in a custom control, and then attempt to close one of them (via the "x" button on the tab). However, when I look at what events are triggered by this action in the "PdfCtl_OnEvent" function, I see the following chain:
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65537
pdfCtl.OnEvent: EventID==2420 / EventDisplayName==e.document.modStateChanged / CoreDoc.ID==65537
pdfCtl.OnEvent: EventID==2397 / EventDisplayName==e.document.activated / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2389 / EventDisplayName==e.activeDocChanged / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2399 / EventDisplayName==e.document.closed / CoreDoc.ID==65542
As you can see, the "beforeclosed" event for document 65537 is triggered, but not the "closed" event. Strangely, a "closed" event is later triggered - however, this is for document 65542, which remains open in the control. It is worth noting that this behaviour occurs regardless of whether the tab being closed is the active tab or not. This is causing us problems, as we are not able to correctly communicate with our back-end system which document(s) have been edited and/or closed.
This problem gets worse when we attempt to close all open tabs simultaneously. To illustrate this problem, I opened 3 documents in the control, and then closed the main form of my application. Here is the output I received from the "PdfCtl_OnEvent" function:
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65545
pdfCtl.OnEvent: EventID==2420 / EventDisplayName==e.document.modStateChanged / CoreDoc.ID==65545
pdfCtl.OnEvent: EventID==2397 / EventDisplayName==e.document.activated / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2389 / EventDisplayName==e.activeDocChanged / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2399 / EventDisplayName==e.document.closed / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65544
pdfCtl.OnEvent: EventID==2397 / EventDisplayName==e.document.activated / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2389 / EventDisplayName==e.activeDocChanged / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2399 / EventDisplayName==e.document.closed / CoreDoc.ID==65542
pdfCtl.OnEvent: EventID==2398 / EventDisplayName==e.document.beforeClose / CoreDoc.ID==65542
Again, the "closed" event is not triggered for the first document. However, in this case the "closed" event IS then triggered for the remaining 2 documents. However, for these documents the "beforeclosed" event is triggered AFTER the "closed" event. We are also finding that after this output is generated, we receive a System.NullReferenceException when trying to access the "pdfCtl.Doc.CoreDoc.ID" property (also in the "PdfCtl_OnEvent" function).
I am unsure why this is happening... Should you require any further details to help get to the bottom of this, please do let me know!
// Martin