Fixing text selection seg fault in text tool