Fix a bug when tearing off tabs of a tab widget