Redraw Triggers Discard EditOperation

743
3
07-29-2020 10:39 AM
KrisCulin
Occasional Contributor

Hello,

I've been working to handle several use cases around the EditCompletedType via the EditCompleted event.  One of them is EditCompletedType.Discard.

However, i found that when Redraw is called thru code or the refresh button in the UI (in the status bar) are used, it triggers an EditOperation using EditCompleteType.Discard.

The comments for EditCompleted.Discard read

Indicates this EditCompletedEvent discards outstanding edits to the database.

This interferes with the Discard button on the Edit tab.  I need to know when this button is pressed so I can sync our own undo operations with ArcGIS Pro's.  However, Discard is used in two distinct use cases and I cannot find any difference between them.

Two Questions:

1. Assuming you can confirm this finding (I've attached a simple add-in that reproduces it), will it be patched ASAP?

2. Is there a work around?  Is there a way to distinguish the Discard between a refresh and clicking the Discard button?

I am currently using ArcGIS Pro SDK 2.5.  We plan to update to 2.6 in the very near future.  If the fix will be in 2.6 it will move us quicker to that version.

TIA.

Kris

0 Kudos
3 Replies
by Anonymous User
Not applicable

Hi Kris,

Yes I can confirm this is an issue in 2.5 and unfortunately 2.6.

It is planned to be fixed in 2.7. I cant think of any reliable workarounds.

0 Kudos
KrisCulin
Occasional Contributor

Thanks Sean.

Is there any possibility of a patch?  Or is it too complicated to patch the issue? (I know the feeling). 

The reason I ask is that we keep our own undo stack in sync with AGP's.  If a user uses the Discard button the undo stacks are no longer in-sync within each other and that will cause unknown issues.  Since the Redraw and Discard buttons have no distinguishing difference in the EditCompletedEventArgs, we have no way of know when we should be handling it at the right time.

We plan to release our product in September that works within ArcGIS Pro.  We will most likely use the 2.6 SDK and require our users to be on ArcGIS Pro 2.6 (not officially decided but it is most likely).

So if there is any way to get a patch released to fix this issue it would be greatly - more than - appreciated.

Kris

KrisCulin
Occasional Contributor

Hey Sean,

After taking another crack at this issue, I figured out a work around for us to use for the short-term until a patch can be provided (preferred, of course).

I found that in the EditCompleted event handler, if I check

Project.Current.HasEdits && Project.Current.EditedDataStores.Length == 0

that this is only occurring when you use the Discard button.  When the refresh button is used, this is not usually the case.  Even if it was, it just means that there is nothing on your undo stack and therefore none on ours (so clearing ours again would not cause any side-effects).

I thought you would like to know what I found.  I've implemented this logic into our handler and it is working exactly as I hoped - discard will discard the edits and I can handle that accordingly.  And I can ignore the refresh.

I realize this check only works when there is one data store (i.e. single file geodatabase).  But this is just a short-term, temporary way to handle the issue.  We plan to support multiple geodatabases (a 1-1 relationship between gdb and one of our projects).  I'll add additional logic to handle that once we get to that point.

Kris