fix #1232 Check tpl context still exists on widget

Just check that the associated template context for a widget still exists
before trying to execute a given callback on it.

Fixes #1232
Close #1233
1.4.17J