No JTAG Device found

I've been using Atmel Studio 7 and an Atmel-ICE programmer on a Mega2560 for a week or so. I have to use global variables to see what's going on, but I did that all the time 30+ years ago so I guess I can do it again.

There is one irritating problem that crops up seemingly at random. I'd be running in the JTAG environment, debugging code, make a few adjustments to the code, rebuild and run another debug session. Then, at random, for some unknown reason when I try to start another debug session it comes back with an error message that no JTAG device could be found.

So Iturn off the power, pull all the wires, plug in the ISP header and power connection, fire it up and sure enough the OCDEN fuse has been cleared. Once or twice the JTAGEN fuse has been cleared as well. It's not a terrible problem as I can reset the fuses and get things running again, but it is a real irritation to break your thought process to fix something that should just be left alone.

Does anybody have a clue what might be causing this?