File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -151,35 +151,50 @@ struct widget_js_base : public ui::widget_flex {
151151 on_update (ctx);
152152 }
153153
154+ auto weak = weak_from_this ();
154155 if (ctx.hovered (this ) && ctx.mouse_clicked && on_click) {
155156 on_click (0 );
157+ if (weak.expired ())
158+ return ;
156159 }
157160
158161 if (ctx.hovered (this ) && !previous_hovered && on_mouse_enter) {
159162 on_mouse_enter ();
163+ if (weak.expired ())
164+ return ;
160165 } else if (!ctx.hovered (this ) && previous_hovered && on_mouse_leave) {
161166 on_mouse_leave (ctx);
167+ if (weak.expired ())
168+ return ;
162169 }
163170
164171 previous_hovered = ctx.hovered (this );
165172 if (ctx.mouse_down_on (this ) && on_mouse_down) {
166173 on_mouse_down (ctx);
174+ if (weak.expired ())
175+ return ;
167176 }
168177
169178 if (ctx.mouse_up && on_mouse_up) {
170179 on_mouse_up (ctx);
180+ if (weak.expired ())
181+ return ;
171182 }
172183
173184 if (ctx.mouse_x != prev_mouse_x || ctx.mouse_y != prev_mouse_y) {
174185 prev_mouse_x = ctx.mouse_x ;
175186 prev_mouse_y = ctx.mouse_y ;
176187 if (on_mouse_move && ctx.hovered (this )) {
177188 on_mouse_move (ctx.mouse_x , ctx.mouse_y );
189+ if (weak.expired ())
190+ return ;
178191 }
179192 }
180193
181194 if (ctx.scroll_y != 0 && on_mouse_wheel) {
182195 on_mouse_wheel (ctx);
196+ if (weak.expired ())
197+ return ;
183198 }
184199 } catch (const std::exception &e) {
185200 std::cerr << " Exception in widget update: " << e.what () << std::endl;
You can’t perform that action at this time.
0 commit comments