File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ pub const Session = struct {
7373 window : Window ,
7474 // TODO move the shed to the browser?
7575 storageShed : storage.Shed ,
76+ page : ? * Page = null ,
7677
7778 jstypes : [Types .len ]usize = undefined ,
7879
@@ -95,6 +96,8 @@ pub const Session = struct {
9596 }
9697
9798 fn deinit (self : * Session ) void {
99+ if (self .page ) | page | page .end ();
100+
98101 self .env .deinit ();
99102 self .arena .deinit ();
100103
@@ -129,11 +132,14 @@ pub const Page = struct {
129132 fn init (
130133 alloc : std.mem.Allocator ,
131134 session : * Session ,
132- ) Page {
133- return Page {
135+ ) ! Page {
136+ if (session .page != null ) return error .SessionPageExists ;
137+ var page = Page {
134138 .arena = std .heap .ArenaAllocator .init (alloc ),
135139 .session = session ,
136140 };
141+ session .page = & page ;
142+ return page ;
137143 }
138144
139145 // reset js env and mem arena.
@@ -149,6 +155,7 @@ pub const Page = struct {
149155
150156 pub fn deinit (self : * Page ) void {
151157 self .arena .deinit ();
158+ self .session .page = null ;
152159 }
153160
154161 // dump writes the page content into the given file.
You can’t perform that action at this time.
0 commit comments