I made a really little modification on your code.
Before the modification, the problem was:
At the beginning, if we want to choose a file, we can click on "Open file". Then, it opens a window where we can choose our file and "confirm" but we can also decide to "cancel". When we "cancel", the program automatically choose our layout.
I think an image will be more understandable:
As I said before, I made a really little modification: I just put the method which will confirm/accept the layout only if we choose a file.
EDIT:
Sorry, I didn't actualise the develop branch. I see that the problem was corrected.
I made a really little modification on your code. Before the modification, the problem was: At the beginning, if we want to choose a file, we can click on "Open file". Then, it opens a window where we can choose our file and "confirm" but we can also decide to "cancel". When we "cancel", the program automatically choose our layout.
I think an image will be more understandable:
As I said before, I made a really little modification: I just put the method which will confirm/accept the layout only if we choose a file.
EDIT: Sorry, I didn't actualise the develop branch. I see that the problem was corrected.