If an add-in tool is active, it looks like when you open a chart, OnToolActivateAsync fires again, causing my code to be executed again. Furthermore, when I close the chart, ArcGIS Pro crashes. https://utexas.box.com/s/qx1kidxsnufrgsobw1f83wd3aravjiho
Is there any way to prevent the multifiring of OnToolActivateAsync? And not crashing would be nice.
I'm in ArcGIS Pro 2.5.0.
To test this:
1. Make an add-in with a Pro MapTool. No need for any additional code. Build (I built under Debug/Any CPU).
2. In Visual Studio, click Start. Place a breakpoint in OnToolActivateAsync on the line:
<SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">base</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">OnToolActivateAsync</SPAN><SPAN class="punctuation token">(</SPAN>active<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// breakpoint here</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
3. Start a Pro project with a map. Add a table and make a chart. I tried line and bar charts from two numbers fields and the result was the same, so I suspect chart type doesn't matter. If the chart pane is open, then close it.
4. On the Add-In tab, click the tool to activate it. You should the breakpoint. Press F5 to let code execution continue.
5. Open the chart. When I do this, I hit the breakpoint again. It seems like I shouldn't hit the breakpoint unless I had clicked to activate my tool again.
6. Click the x to close the chart. When I do this, Pro crashes.
Attached are sample data, map file, and add-in code for a quick test.
I think the crashing is a bug, and I sent the above description in the crash report. I'm posting the question here primarily to answer the question about how to prevent OnToolActivateAsync from firing when a chart is opened. Thanks!