Unless a person is mentally deficient enough to be placed on at least a 72-hour involuntary hold by authorities and then after having at least two mental professionals diagnosed and then in court adjudicated as such, they should not lose the right to keep and bear arms..
I think in order for your criteria to work, society would need to become more efficient at being able to get people diagnosed as such, but as it stands, somebody mentally unstable can skirt by avoiding such, until the moment they go over the edge.
I still believe family is the key, they are first to know, if there is to be new legislation, empower the family. A majority of mass shooters have had family's who knew their loved ones were sick.
To use the uni-bomber as an example, it took family to stop him from killing more than he did, and I believe if family is given more leeway, even special leeway, that could be a major improvement.