I think it is ok to gamble, even when worried, in trouble, bored, lonely, in grief, or lost, as long as the gambling does not impact significantly on someone's life, especially in working/family/relationships. I mean, if occasionally one is gambling as an act of self-harm, say burning a day worth of salary, it is still ok, as long as the gamble does not affect his/her living conditions, or the people he/she loves.
Gambling per se is not a bad thing.