Fix assertion on trying to select a file (#2737).
authorCarl Hetherington <cth@carlh.net>
Fri, 26 Jan 2024 22:46:57 +0000 (23:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 26 Jan 2024 22:46:57 +0000 (23:46 +0100)
src/wx/file_dialog.cc
src/wx/file_dialog.h

index 5a530359c25bbcfe35880d2bbd59589e6b26ac69..9f547f85a5648890155dd17f7be97efa85ca839b 100644 (file)
@@ -63,6 +63,7 @@ FileDialog::FileDialog(
                style
                )
        , _initial_path_key(initial_path_key)
+       , _multiple(style & wxFD_MULTIPLE)
 {
 
 }
@@ -96,9 +97,14 @@ FileDialog::show()
                return false;
        }
 
-       auto p = paths();
-       DCPOMATIC_ASSERT(!p.empty());
-       Config::instance()->set_initial_path(_initial_path_key, p[0].parent_path());
+       if (_multiple) {
+               auto p = paths();
+               DCPOMATIC_ASSERT(!p.empty());
+               Config::instance()->set_initial_path(_initial_path_key, p[0].parent_path());
+       } else {
+               Config::instance()->set_initial_path(_initial_path_key, path().parent_path());
+       }
+
        return true;
 }
 
index ad8f68aa11a514c037510926e5d975f2e2106ed7..a87c6539515becc62c158eb3ade25e5ae99f4e70 100644 (file)
@@ -52,5 +52,6 @@ public:
 
 private:
        std::string _initial_path_key;
+       bool _multiple;
 };