Fixed segfault on when main window