Gary Oldman was "saved" by 'Harry Potter'.

The 65-year-old actor was granted sole custody of sons Gulliver, now 27, and Charlie, 24, after he divorced their mother, third wife Donya Fiorentino, in 2001 and he will always be grateful for his role as Sirius Black because it granted him some stability and a regular income that meant he could keep working while caring for the boys.

Speaking on 'The Drew Barrymore Show', Gary said: “At 42 years old, I woke up divorced and I had custody of these boys and so that, in itself, was…

"That was hard because there was a shift in the industry where a lot of productions were being [filmed in], it was Hungary, Budapest, Prague, Australia, you know, all of these places.

"So I turned down a lot of work... Thank God for 'Harry Potter'.

“I tell you, the two — 'Batman' and 'Harry Potter '— really they saved me, because it meant that I could do the least amount of work for the most amount of money and then be home with the kids.”

The 'Slow Horses' actor - who also has Alfie, 36, with first wife Lesley Manville, and is stepfather to wife Gisele Schmidt's 15-year-old son William - used to commute from Los Angeles to London to shoot his role as Gotham City Police Department Commissioner Jim Gordon in Christopher Nolan's 'The Dark Knight' trilogy because he didn't want his kids being raised by nannies.

He said: "When we did the first Batman, London doubled for Gotham and I did 27 round trips from LA.

“I’d fly in for a day, I’d do a shoot a day,” he said. “To [Nolan’s] credit, he stayed on schedule and I would go home for three days, come back for two, go home for a weekend, come back for one day… otherwise, I just felt they’re being brought up by a nanny.”

Gary was determined to be a more hands-on parent after being "not there all the time" for Alfie.

He added: “I got the opportunity to have these other two kids and I thought, ‘I can’t. I’ve now been given a real gift to be the dad I imagined I could be with the first boy, Alfie, and so I’ve got a chance to repair this and switch it around.’ "

And the 'Darkest Hour' star is proud his sons grew up to become "nice people".

He said: “My kids are not geniuses, but they’re really, really nice people.

"I think [that we need] more nice people in the world. We’ve got geniuses, we’ve done enough of them. We need really kind people. Good heart and not mean-spirited.

“I think they saved my life.”