BUG:385717 check whether the button was pressed.
This makes sure that file layers don't have their file opened on other files too.
This should be backported. Ref T6475