mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibGUI: Add GUI::Window::try_set_main_widget<T>(...)
This is a fallible variant of set_main_widget<T>() that returns ErrorOr.
This commit is contained in:
parent
bde9c2bc65
commit
dc47fce2d9
1 changed files with 8 additions and 0 deletions
|
@ -135,6 +135,14 @@ public:
|
|||
const Widget* main_widget() const { return m_main_widget; }
|
||||
void set_main_widget(Widget*);
|
||||
|
||||
template<class T, class... Args>
|
||||
inline ErrorOr<NonnullRefPtr<T>> try_set_main_widget(Args&&... args)
|
||||
{
|
||||
auto widget = TRY(T::try_create(forward<Args>(args)...));
|
||||
set_main_widget(widget.ptr());
|
||||
return widget;
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
inline T& set_main_widget(Args&&... args)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue