Skip to content

Commit 58a3710

Browse files
authored
Merge pull request #4 from DenisKolodin/save-fix
Fix bug with Save Dialog
2 parents 50c0b5d + d7da0eb commit 58a3710

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
130130
let ptr_out_path = &mut out_path as *mut *mut c_char;
131131

132132
let mut out_multiple = nfdpathset_t::default();
133-
let ptr_out_multyple = &mut out_multiple as *mut nfdpathset_t;
133+
let ptr_out_multiple = &mut out_multiple as *mut nfdpathset_t;
134134

135135
unsafe {
136136
result = match dialog_type {
@@ -139,7 +139,7 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
139139
},
140140

141141
DialogType::MultipleFiles => {
142-
NFD_OpenDialogMultiple(filter_list_ptr, default_path_ptr, ptr_out_multyple)
142+
NFD_OpenDialogMultiple(filter_list_ptr, default_path_ptr, ptr_out_multiple)
143143
},
144144

145145
DialogType::SaveFile => {
@@ -149,9 +149,7 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
149149

150150
match result {
151151
nfdresult_t::NFD_OKAY =>{
152-
if dialog_type == DialogType::SingleFile {
153-
Ok(Response::Okay(CStr::from_ptr(out_path).to_string_lossy().into_owned()))
154-
} else {
152+
if dialog_type == DialogType::MultipleFiles {
155153
let count = NFD_PathSet_GetCount(&out_multiple);
156154
let mut res = Vec::with_capacity(count);
157155
for i in 0..count {
@@ -160,9 +158,11 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
160158

161159
}
162160

163-
NFD_PathSet_Free(ptr_out_multyple);
161+
NFD_PathSet_Free(ptr_out_multiple);
164162

165163
Ok(Response::OkayMultiple(res))
164+
} else {
165+
Ok(Response::Okay(CStr::from_ptr(out_path).to_string_lossy().into_owned()))
166166
}
167167
},
168168

0 commit comments

Comments
 (0)