It's awful, but every time we blame a (white male) terrorist's "mental illness" for his actions, it gets even worse. Being bipolar or depressed doesn't make you a hateful misogynist. Gimme a break.
But I also think that there should psychiatric tests before you're allowed to own a gun. Especially if you have a history of suicidal tendencies, alcoholism (like, if you're been arrested for it), or impulsive, dangerous actions (again, if you've been arrested for it).
I have a friend who has had depression all of her life, and I would not want her to have a gun. Not because she'd be a danger to others - she wouldn't hurt a fly. But because when she feels awful and like an utter failure late at night (which is pretty often, like, once every 2 weeks...at least this is when she texts me saying she might as well kill herself, so she might actually think it to herself even more often), she might reach for that gun instead of getting some sleep to feel better and more coherent in the morning.
Indeed, people who own guns are 3x more likely to commit suicide.