Skip to content

Commit 25de592

Browse files
authored
set nil as the initial value of the struct reference type fields (#558)
1 parent f6f9a4c commit 25de592

19 files changed

+54
-54
lines changed

component/accordion.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import gx
66
@[heap]
77
pub struct AccordionComponent {
88
pub mut:
9-
layout &ui.Stack // required
9+
layout &ui.Stack = unsafe { nil } // required
1010
titles map[string]string
1111
selected map[string]bool
1212
views map[string]int

component/alpha.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ pub struct AlphaComponent {
99
pub mut:
1010
id string
1111
alpha int
12-
layout &ui.Stack
13-
slider &ui.Slider
14-
textbox &ui.TextBox
15-
on_changed AlphaFn = AlphaFn(0)
12+
layout &ui.Stack = unsafe { nil }
13+
slider &ui.Slider = unsafe { nil }
14+
textbox &ui.TextBox = unsafe { nil }
15+
on_changed AlphaFn = AlphaFn(0)
1616
}
1717

1818
@[params]

component/colorbox.v

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ mut:
4747
hsl bool // use hsl instead of hsv
4848
drag bool // drag mode for canvas on h
4949
pub mut:
50-
layout &ui.Stack // required
51-
cv_h &ui.CanvasLayout
52-
cv_sv &ui.CanvasLayout
53-
r_rgb_cur &ui.Rectangle
54-
cv_hsv_sel &ui.CanvasLayout
55-
tb_r &ui.TextBox
56-
tb_g &ui.TextBox
57-
tb_b &ui.TextBox
58-
lb_r &ui.Label
59-
lb_g &ui.Label
60-
lb_b &ui.Label
50+
layout &ui.Stack = unsafe { nil } // required
51+
cv_h &ui.CanvasLayout = unsafe { nil }
52+
cv_sv &ui.CanvasLayout = unsafe { nil }
53+
r_rgb_cur &ui.Rectangle = unsafe { nil }
54+
cv_hsv_sel &ui.CanvasLayout = unsafe { nil }
55+
tb_r &ui.TextBox = unsafe { nil }
56+
tb_g &ui.TextBox = unsafe { nil }
57+
tb_b &ui.TextBox = unsafe { nil }
58+
lb_r &ui.Label = unsafe { nil }
59+
lb_g &ui.Label = unsafe { nil }
60+
lb_b &ui.Label = unsafe { nil }
6161
}
6262

6363
@[params]

component/colorbutton.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ type ColorButtonFn = fn (b &ColorButtonComponent)
88
@[heap]
99
pub struct ColorButtonComponent {
1010
pub mut:
11-
widget &ui.Button
12-
bg_color gx.Color = gx.white
11+
widget &ui.Button = unsafe { nil }
12+
bg_color gx.Color = gx.white
1313
alpha int
1414
on_click ColorButtonFn = ColorButtonFn(0)
1515
on_changed ColorButtonFn = ColorButtonFn(0)

component/colorpalette.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import math
88
pub struct ColorPaletteComponent {
99
pub mut:
1010
id string
11-
layout &ui.Stack // required
12-
colbtn &ui.Button // current
11+
layout &ui.Stack = unsafe { nil } // required
12+
colbtn &ui.Button = unsafe { nil } // current
1313
ncolors int
1414
alpha &AlphaComponent = unsafe { nil }
1515
color &gx.Color = unsafe { nil }

component/colorsliders.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type ColorSlidersFn = fn (cs &ColorSlidersComponent)
1515
pub struct ColorSlidersComponent {
1616
id string
1717
pub mut:
18-
layout &ui.Stack // required
18+
layout &ui.Stack = unsafe { nil } // required
1919
orientation ui.Orientation
2020
r_slider &ui.Slider = unsafe { nil }
2121
r_textbox &ui.TextBox = unsafe { nil }

component/double_listbox.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import ui
55
@[heap]
66
pub struct DoubleListBoxComponent {
77
pub mut:
8-
layout &ui.Stack // required
9-
lb_left &ui.ListBox
10-
lb_right &ui.ListBox
11-
btn_left &ui.Button
12-
btn_right &ui.Button
13-
btn_clear &ui.Button
8+
layout &ui.Stack = unsafe { nil } // required
9+
lb_left &ui.ListBox = unsafe { nil }
10+
lb_right &ui.ListBox = unsafe { nil }
11+
btn_left &ui.Button = unsafe { nil }
12+
btn_right &ui.Button = unsafe { nil }
13+
btn_clear &ui.Button = unsafe { nil }
1414
}
1515

1616
@[params]

component/filebrowser.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import os
77
@[heap]
88
pub struct FileBrowserComponent {
99
pub mut:
10-
layout &ui.Stack
11-
btn_cancel &ui.Button
12-
btn_ok &ui.Button
10+
layout &ui.Stack = unsafe { nil }
11+
btn_cancel &ui.Button = unsafe { nil }
12+
btn_ok &ui.Button = unsafe { nil }
1313
tv &TreeViewComponent = unsafe { nil }
1414
dir string
1515
}

component/fontbutton.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import gx
66
@[heap]
77
pub struct FontButtonComponent {
88
pub mut:
9-
btn &ui.Button
9+
btn &ui.Button = unsafe { nil }
1010
dtw ui.DrawTextWidget
1111
}
1212

component/fontchooser.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const (
1111
@[heap]
1212
pub struct FontChooserComponent {
1313
pub mut:
14-
layout &ui.Stack // required
14+
layout &ui.Stack = unsafe { nil } // required
1515
dtw ui.DrawTextWidget
1616
}
1717

component/grid.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type GridData = Factor | []bool | []f64 | []int | []string
2525
pub struct GridComponent {
2626
pub mut:
2727
id string
28-
layout &ui.CanvasLayout
28+
layout &ui.CanvasLayout = unsafe { nil }
2929
vars []GridVar
3030
types []GridType
3131
formula_mngr GridFormulaMngr

component/hideable.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import gx
77
pub struct HideableComponent {
88
pub mut:
99
id string
10-
layout &ui.Stack
10+
layout &ui.Stack = unsafe { nil }
1111
child_layout_id string
1212
window &ui.Window = &ui.Window(unsafe { nil })
1313
z_index map[string]int
@@ -20,8 +20,8 @@ pub mut:
2020
pub struct HideableParams {
2121
id string
2222
bg_color gx.Color
23-
layout &ui.Stack
24-
hidden bool = true
23+
layout &ui.Stack = unsafe { nil }
24+
hidden bool = true
2525
shortcut string
2626
open bool = true
2727
}

component/menufile.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub type MenuFileFn = fn (&MenuFileComponent)
1010
pub struct MenuFileComponent {
1111
pub mut:
1212
id string
13-
layout &ui.Stack
13+
layout &ui.Stack = unsafe { nil }
1414
hidden_files bool
1515
file string
1616
folder_to_open string

component/messagebox.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ type MessageBoxFn = fn (&MessageBoxComponent)
77
@[heap]
88
pub struct MessageBoxComponent {
99
id string
10-
layout &ui.Stack
11-
tb &ui.TextBox
12-
btn &ui.Button
10+
layout &ui.Stack = unsafe { nil }
11+
tb &ui.TextBox = unsafe { nil }
12+
btn &ui.Button = unsafe { nil }
1313
text string
1414
on_click MessageBoxFn = MessageBoxFn(0)
1515
}

component/rasterview.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type RasterViewFn = fn (rv &RasterViewComponent)
1212
pub struct RasterViewComponent {
1313
pub mut:
1414
id string
15-
layout &ui.CanvasLayout
16-
r &libvg.Raster
15+
layout &ui.CanvasLayout = unsafe { nil }
16+
r &libvg.Raster = unsafe { nil }
1717
// width int
1818
// height int
1919
// channels int = 4

component/settings.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ pub struct SettingFont {
1111
param string
1212
lb_text string
1313
mut:
14-
layout &ui.Stack
15-
lb_param &ui.Label
16-
lb_font &ui.Label
17-
btn_font &ui.Button
14+
layout &ui.Stack = unsafe { nil }
15+
lb_param &ui.Label = unsafe { nil }
16+
lb_font &ui.Label = unsafe { nil }
17+
btn_font &ui.Button = unsafe { nil }
1818
}
1919

2020
@[params]

component/splitpanel.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const splitpanel_btn_size = 6
99
pub struct SplitPanelComponent {
1010
pub mut:
1111
id string
12-
layout &ui.Stack
13-
child1 &ui.Widget
14-
child2 &ui.Widget
12+
layout &ui.Stack = unsafe { nil }
13+
child1 &ui.Widget = unsafe { nil }
14+
child2 &ui.Widget = unsafe { nil }
1515
direction ui.Direction
1616
active bool
1717
weight f32
@@ -21,8 +21,8 @@ pub mut:
2121
@[params]
2222
pub struct SplitPanelParams {
2323
id string
24-
child1 &ui.Widget
25-
child2 &ui.Widget
24+
child1 &ui.Widget = unsafe { nil }
25+
child2 &ui.Widget = unsafe { nil }
2626
direction ui.Direction = .row
2727
weight f64 = 50.0
2828
btn_size int = component.splitpanel_btn_size

component/tabs.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ enum TabsMode {
1212
pub struct TabsComponent {
1313
pub mut:
1414
id string
15-
layout &ui.Stack // required
15+
layout &ui.Stack = unsafe { nil } // required
1616
active string
1717
prev_active string
18-
tab_bar &ui.Stack
18+
tab_bar &ui.Stack = unsafe { nil }
1919
pages map[string]ui.Widget
2020
z_index map[string]int
2121
mode TabsMode

component/treeview.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ type TreeViewClickFn = fn (c &ui.CanvasLayout, mut tv TreeViewComponent)
115115
pub struct TreeViewComponent {
116116
pub mut:
117117
id string
118-
layout &ui.Stack // required
118+
layout &ui.Stack = unsafe { nil } // required
119119
trees []Tree
120120
icon_paths map[string]string
121121
text_color gx.Color

0 commit comments

Comments
 (0)