6526: Check for invalid handle

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/trunk@21653 4ae1f11a-8b86-4847-b8af-ab372f36d1fd