gpui: Improve some log_err calls in windows backend (#40717)
Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -951,17 +951,30 @@ fn file_save_dialog(
|
||||
) -> Result<Option<PathBuf>> {
|
||||
let dialog: IFileSaveDialog = unsafe { CoCreateInstance(&FileSaveDialog, None, CLSCTX_ALL)? };
|
||||
if !directory.to_string_lossy().is_empty()
|
||||
&& let Some(full_path) = directory.canonicalize().log_err()
|
||||
&& let Some(full_path) = directory
|
||||
.canonicalize()
|
||||
.context("failed to canonicalize directory")
|
||||
.log_err()
|
||||
{
|
||||
let full_path = SanitizedPath::new(&full_path);
|
||||
let full_path_string = full_path.to_string();
|
||||
let path_item: IShellItem =
|
||||
unsafe { SHCreateItemFromParsingName(&HSTRING::from(full_path_string), None)? };
|
||||
unsafe { dialog.SetFolder(&path_item).log_err() };
|
||||
unsafe {
|
||||
dialog
|
||||
.SetFolder(&path_item)
|
||||
.context("failed to set dialog folder")
|
||||
.log_err()
|
||||
};
|
||||
}
|
||||
|
||||
if let Some(suggested_name) = suggested_name {
|
||||
unsafe { dialog.SetFileName(&HSTRING::from(suggested_name)).log_err() };
|
||||
unsafe {
|
||||
dialog
|
||||
.SetFileName(&HSTRING::from(suggested_name))
|
||||
.context("failed to set file name")
|
||||
.log_err()
|
||||
};
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
||||
@@ -169,7 +169,9 @@ impl WindowsWindowState {
|
||||
length: std::mem::size_of::<WINDOWPLACEMENT>() as u32,
|
||||
..Default::default()
|
||||
};
|
||||
GetWindowPlacement(self.hwnd, &mut placement).log_err();
|
||||
GetWindowPlacement(self.hwnd, &mut placement)
|
||||
.context("failed to get window placement")
|
||||
.log_err();
|
||||
placement
|
||||
};
|
||||
(
|
||||
@@ -254,7 +256,9 @@ impl WindowsWindowInner {
|
||||
lock.fullscreen_restore_bounds = window_bounds;
|
||||
let style = WINDOW_STYLE(unsafe { get_window_long(this.hwnd, GWL_STYLE) } as _);
|
||||
let mut rc = RECT::default();
|
||||
unsafe { GetWindowRect(this.hwnd, &mut rc) }.log_err();
|
||||
unsafe { GetWindowRect(this.hwnd, &mut rc) }
|
||||
.context("failed to get window rect")
|
||||
.log_err();
|
||||
let _ = lock.fullscreen.insert(StyleAndBounds {
|
||||
style,
|
||||
x: rc.left,
|
||||
@@ -301,15 +305,20 @@ impl WindowsWindowInner {
|
||||
};
|
||||
match open_status.state {
|
||||
WindowOpenState::Maximized => unsafe {
|
||||
SetWindowPlacement(self.hwnd, &open_status.placement)?;
|
||||
SetWindowPlacement(self.hwnd, &open_status.placement)
|
||||
.context("failed to set window placement")?;
|
||||
ShowWindowAsync(self.hwnd, SW_MAXIMIZE).ok()?;
|
||||
},
|
||||
WindowOpenState::Fullscreen => {
|
||||
unsafe { SetWindowPlacement(self.hwnd, &open_status.placement)? };
|
||||
unsafe {
|
||||
SetWindowPlacement(self.hwnd, &open_status.placement)
|
||||
.context("failed to set window placement")?
|
||||
};
|
||||
self.toggle_fullscreen();
|
||||
}
|
||||
WindowOpenState::Windowed => unsafe {
|
||||
SetWindowPlacement(self.hwnd, &open_status.placement)?;
|
||||
SetWindowPlacement(self.hwnd, &open_status.placement)
|
||||
.context("failed to set window placement")?;
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user