File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ void gui::set_root(utki::shared_ref<ruis::widget> w)
113113 throw std::invalid_argument (" given widget is already added to some container" );
114114 }
115115
116+ if (w.get ().context .to_shared_ptr () != this ->context .to_shared_ptr ()) {
117+ throw std::invalid_argument (" cannot set root widget from another GUI context" );
118+ }
119+
116120 this ->root_widget = std::move (w);
117121
118122 this ->root_widget .get ().move_to (ruis::vector2 (0 ));
Original file line number Diff line number Diff line change @@ -270,6 +270,10 @@ widget_list::const_iterator container::insert_internal(
270270 throw std::invalid_argument (" container::insert(): the widget is already added to some other container" );
271271 }
272272
273+ if (ww.context .to_shared_ptr () != this ->context .to_shared_ptr ()) {
274+ throw std::invalid_argument (" container::insert(): cannot insert widget from another GUI context" );
275+ }
276+
273277 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access)
274278 auto ret = this ->children_list .variable .emplace (
275279 before, //
You can’t perform that action at this time.
0 commit comments