core & ui_qt: fix bug/crash when opening a new file when a file is already opened