Fixed issue #2127: After delete last tag in Browse references, tree of refs disappeared

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>
Prevent from using invalid handle

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>