Skip to content

Commit 2fb2a10

Browse files
committed
fix: avoid loading/saving zero width/height
1 parent bd73b8a commit 2fb2a10

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Fixed failure to start sometimes when saved width or height is zero.
8+
59
## [0.6.2] - 2025-04-17
610

711
### Fixed

src/window_registry_info.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ impl WindowRegistryInfo {
4747

4848
let x = get_str(&key, WINDOW_POS_X_KEY, defaults.x);
4949
let y = get_str(&key, WINDOW_POS_Y_KEY, defaults.y);
50-
let width = get_str(&key, WINDOW_SIZE_WIDTH_KEY, defaults.width);
51-
let height = get_str(&key, WINDOW_SIZE_HEIGHT_KEY, defaults.height);
50+
let mut width = get_str(&key, WINDOW_SIZE_WIDTH_KEY, defaults.width);
51+
if width < 0 {
52+
width = defaults.width;
53+
}
54+
let mut height = get_str(&key, WINDOW_SIZE_HEIGHT_KEY, defaults.height);
55+
if height < 0 {
56+
height = defaults.height;
57+
}
5258
let auto_width = get_bool(&key, WINDOW_SIZE_AUTO_WIDTH_KEY, defaults.auto_width);
5359
let auto_height = get_bool(&key, WINDOW_SIZE_AUTO_HEIGHT_KEY, defaults.auto_height);
5460

@@ -72,8 +78,12 @@ impl WindowRegistryInfo {
7278
let key = CURRENT_USER.create(APP_REG_KEY)?;
7379
key.set_string(WINDOW_POS_X_KEY, &self.x.to_string())?;
7480
key.set_string(WINDOW_POS_Y_KEY, &self.y.to_string())?;
75-
key.set_string(WINDOW_SIZE_WIDTH_KEY, &self.width.to_string())?;
76-
key.set_string(WINDOW_SIZE_HEIGHT_KEY, &self.height.to_string())?;
81+
if self.width > 0 {
82+
key.set_string(WINDOW_POS_X_KEY, &self.x.to_string())?;
83+
}
84+
if self.height > 0 {
85+
key.set_string(WINDOW_POS_Y_KEY, &self.y.to_string())?;
86+
}
7787
key.set_u32(WINDOW_SIZE_AUTO_WIDTH_KEY, self.auto_width as _)?;
7888
key.set_u32(WINDOW_SIZE_AUTO_HEIGHT_KEY, self.auto_height as _)?;
7989

0 commit comments

Comments
 (0)