An unloaded gun is pretty worthless. Maybe the deputies need more training or they should allow other people to carry concealed in the courthouse.
Or maybe they should put their pistols on short lanyards. It's not foolproof, but it should allow them to stop most who would do this.