GFileChooser: fix various issues that could lead to a crash

r? @frank-trampe

cc #1640 (for the second part, at least).
Got this crash after fixing the first one.