A transfer switch should take care of this but it has to transfer all three conductors including the ground.The boat should have the appropriate lock outs so that can't happen, so there is only one source of power to a circuit. .
Unplugging the shorepower cord does the same thing, but as I posted above, there's a good chance of this not happening due to human error.