GUI2/Window: don't create raw window pointers
This commit is contained in:
parent
e996a30603
commit
7bdd72886d
8 changed files with 15 additions and 16 deletions
|
@ -46,11 +46,11 @@ namespace gui2
|
|||
* be tuned. This page will describe what can be tuned.
|
||||
*
|
||||
*/
|
||||
window* build(const builder_window::window_resolution& definition)
|
||||
std::unique_ptr<window> build(const builder_window::window_resolution& definition)
|
||||
{
|
||||
// We set the values from the definition since we can only determine the
|
||||
// best size (if needed) after all widgets have been placed.
|
||||
window* win = new window(definition);
|
||||
auto win = std::make_unique<window>(definition);
|
||||
assert(win);
|
||||
|
||||
for(const auto& lg : definition.linked_groups) {
|
||||
|
@ -75,15 +75,15 @@ window* build(const builder_window::window_resolution& definition)
|
|||
win->init_grid(*definition.grid);
|
||||
}
|
||||
|
||||
win->add_to_keyboard_chain(win);
|
||||
win->add_to_keyboard_chain(win.get());
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
window* build(const std::string& type)
|
||||
std::unique_ptr<window> build(const std::string& type)
|
||||
{
|
||||
const builder_window::window_resolution& definition = get_window_builder(type);
|
||||
window* window = build(definition);
|
||||
auto window = build(definition);
|
||||
window->set_id(type);
|
||||
return window;
|
||||
}
|
||||
|
|
|
@ -208,11 +208,11 @@ private:
|
|||
* @param type The type id string of the window, this window
|
||||
* must be registered at startup.
|
||||
*/
|
||||
window* build(const std::string& type);
|
||||
std::unique_ptr<window> build(const std::string& type);
|
||||
|
||||
/**
|
||||
* Builds a window.
|
||||
*/
|
||||
window* build(const builder_window::window_resolution& res);
|
||||
std::unique_ptr<window> build(const builder_window::window_resolution& res);
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -74,7 +74,7 @@ bool modal_dialog::show(const unsigned auto_close_time)
|
|||
return false;
|
||||
}
|
||||
|
||||
window_.reset(build_window());
|
||||
window_ = build_window();
|
||||
assert(window_.get());
|
||||
|
||||
post_build(*window_);
|
||||
|
@ -218,7 +218,7 @@ field_label* modal_dialog::register_label(const std::string& id,
|
|||
return field;
|
||||
}
|
||||
|
||||
window* modal_dialog::build_window() const
|
||||
std::unique_ptr<window> modal_dialog::build_window() const
|
||||
{
|
||||
return build(window_id());
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ private:
|
|||
*
|
||||
* @returns The window to show.
|
||||
*/
|
||||
window* build_window() const;
|
||||
std::unique_ptr<window> build_window() const;
|
||||
|
||||
/**
|
||||
* Actions to be taken directly after the window is build.
|
||||
|
|
|
@ -41,7 +41,7 @@ void modeless_dialog::show(const bool allow_interaction, const unsigned /*auto_c
|
|||
|
||||
hide();
|
||||
|
||||
window_.reset(build_window());
|
||||
window_ = build_window();
|
||||
|
||||
post_build(*window_);
|
||||
|
||||
|
@ -67,7 +67,7 @@ void modeless_dialog::hide()
|
|||
window_.reset(nullptr); }
|
||||
}
|
||||
|
||||
window* modeless_dialog::build_window() const
|
||||
std::unique_ptr<window> modeless_dialog::build_window() const
|
||||
{
|
||||
return build(window_id());
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ private:
|
|||
*
|
||||
* @returns The window to show.
|
||||
*/
|
||||
window* build_window() const;
|
||||
std::unique_ptr<window> build_window() const;
|
||||
|
||||
/**
|
||||
* Actions to be taken directly after the window is build.
|
||||
|
|
|
@ -62,7 +62,7 @@ class distributor;
|
|||
class window : public panel
|
||||
{
|
||||
friend class debug_layout_graph;
|
||||
friend window* build(const builder_window::window_resolution&);
|
||||
friend std::unique_ptr<window> build(const builder_window::window_resolution&);
|
||||
friend struct window_implementation;
|
||||
friend class invalidate_layout_blocker;
|
||||
friend class pane;
|
||||
|
|
|
@ -66,8 +66,7 @@ int intf_show_dialog(lua_State* L)
|
|||
config def_cfg = luaW_checkconfig(L, 1);
|
||||
gui2::builder_window::window_resolution def(def_cfg);
|
||||
|
||||
std::unique_ptr<gui2::window> wp;
|
||||
wp.reset(gui2::build(def));
|
||||
std::unique_ptr<gui2::window> wp(gui2::build(def));
|
||||
|
||||
if(!lua_isnoneornil(L, 2)) {
|
||||
lua_pushvalue(L, 2);
|
||||
|
|
Loading…
Add table
Reference in a new issue