Refactored GUI2's uses of boost::intrusive_ptr

This commit is contained in:
Charles Dang 2016-07-25 01:46:26 +11:00
parent 05092ba2f6
commit 563947e1b3
30 changed files with 143 additions and 155 deletions

View file

@ -1531,15 +1531,15 @@ void tcanvas::parse_cfg(const config& cfg)
DBG_GUI_P << "Canvas: found shape of the type " << type << ".\n";
if(type == "line") {
shapes_.push_back(new tline(data));
shapes_.push_back(std::make_shared<tline>(data));
} else if(type == "rectangle") {
shapes_.push_back(new trectangle(data));
shapes_.push_back(std::make_shared<trectangle>(data));
} else if(type == "circle") {
shapes_.push_back(new tcircle(data));
shapes_.push_back(std::make_shared<tcircle>(data));
} else if(type == "image") {
shapes_.push_back(new timage(data));
shapes_.push_back(std::make_shared<timage>(data));
} else if(type == "text") {
shapes_.push_back(new ttext(data));
shapes_.push_back(std::make_shared<ttext>(data));
} else if(type == "pre_commit") {
/* note this should get split if more preprocessing is used. */

View file

@ -50,7 +50,7 @@ public:
* The other shapes are declared and defined in canvas.cpp, since the
* implementation details are not interesting for users of the canvas.
*/
class tshape : public reference_counted_object
class tshape
{
public:
virtual ~tshape()
@ -71,8 +71,8 @@ public:
= 0;
};
typedef boost::intrusive_ptr<tshape> tshape_ptr;
typedef boost::intrusive_ptr<const tshape> const_tshape_ptr;
typedef std::shared_ptr<tshape> tshape_ptr;
typedef std::shared_ptr<const tshape> const_tshape_ptr;
tcanvas();

View file

@ -27,7 +27,7 @@ namespace gui2
*
* At the moment all states are the same so there is no need to use
* inheritance. If that is needed at some point the containers should contain
* pointers and we should inherit from reference_counted_object.
* pointers
*/
struct tstate_definition
{
@ -38,7 +38,7 @@ struct tstate_definition
/** Base class of a resolution, contains the common keys for a resolution. */
struct tresolution_definition_ : public reference_counted_object
struct tresolution_definition_
{
explicit tresolution_definition_(const config& cfg);
@ -63,10 +63,10 @@ struct tresolution_definition_ : public reference_counted_object
std::vector<tstate_definition> state;
};
typedef boost::intrusive_ptr<tresolution_definition_>
typedef std::shared_ptr<tresolution_definition_>
tresolution_definition_ptr;
typedef boost::intrusive_ptr<const tresolution_definition_>
typedef std::shared_ptr<const tresolution_definition_>
tresolution_definition_const_ptr;
/**
@ -81,13 +81,12 @@ tresolution_definition_const_ptr;
template <class T>
const T& cast(tresolution_definition_const_ptr ptr)
{
boost::intrusive_ptr<const T> conf
= boost::dynamic_pointer_cast<const T>(ptr);
std::shared_ptr<const T> conf = std::make_shared<const T>(ptr);
assert(conf);
return *conf;
}
struct tcontrol_definition : public reference_counted_object
struct tcontrol_definition
{
explicit tcontrol_definition(const config& cfg);
@ -96,7 +95,7 @@ struct tcontrol_definition : public reference_counted_object
{
for (const auto & resolution : cfg.child_range("resolution"))
{
resolutions.push_back(new T(resolution));
resolutions.push_back(std::make_shared<T>(resolution));
}
}
@ -106,7 +105,7 @@ struct tcontrol_definition : public reference_counted_object
std::vector<tresolution_definition_ptr> resolutions;
};
typedef boost::intrusive_ptr<tcontrol_definition> tcontrol_definition_ptr;
typedef std::shared_ptr<tcontrol_definition> tcontrol_definition_ptr;
} // namespace gui2

View file

@ -109,8 +109,8 @@ twindow* build(CVideo& video, const twindow_builder::tresolution* definition)
window->set_click_dismiss(definition->click_dismiss);
boost::intrusive_ptr<const twindow_definition::tresolution>
conf = boost::dynamic_pointer_cast<const twindow_definition::tresolution>(
std::shared_ptr<const twindow_definition::tresolution>
conf = std::static_pointer_cast<const twindow_definition::tresolution>(
window->config());
assert(conf);
@ -169,19 +169,19 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg)
}
if(const config& c = cfg.child("grid")) {
return new tbuilder_grid(c);
return std::make_shared<tbuilder_grid>(c);
}
if(const config& instance = cfg.child("instance")) {
return new implementation::tbuilder_instance(instance);
return std::make_shared<implementation::tbuilder_instance>(instance);
}
if(const config& pane = cfg.child("pane")) {
return new implementation::tbuilder_pane(pane);
return std::make_shared<implementation::tbuilder_pane>(pane);
}
if(const config& viewport = cfg.child("viewport")) {
return new implementation::tbuilder_viewport(viewport);
return std::make_shared<implementation::tbuilder_viewport>(viewport);
}
/*
@ -204,7 +204,8 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg)
#define TRY(name) \
do { \
if(const config& c = cfg.child(#name)) { \
tbuilder_widget_ptr p = new implementation::tbuilder_##name(c); \
tbuilder_widget_ptr p = \
std::make_shared<implementation::tbuilder_##name>(c); \
assert(false); \
} \
} while(0)
@ -410,7 +411,7 @@ twindow_builder::tresolution::tresolution(const config& cfg)
VALIDATE(c, _("No grid defined."));
grid = new tbuilder_grid(c);
grid = std::make_shared<tbuilder_grid>(tbuilder_grid(c));
if(!automatic_placement) {
VALIDATE(width.has_formula() || width(),

View file

@ -17,7 +17,6 @@
#include "gui/auxiliary/formula.hpp"
#include "gui/widgets/grid.hpp"
#include "reference_counted_object.hpp"
#include "utils/functional.hpp"
@ -39,7 +38,7 @@ class twindow;
twindow* build(CVideo& video, const std::string& type);
/** Contains the info needed to instantiate a widget. */
struct tbuilder_widget : public reference_counted_object
struct tbuilder_widget
{
public:
/**
@ -50,7 +49,7 @@ public:
* using and `[instance]' widget this decision can be postponed until
* instantiation.
*/
typedef std::map<std::string, boost::intrusive_ptr<tbuilder_widget> >
typedef std::map<std::string, std::shared_ptr<tbuilder_widget> >
treplacements;
explicit tbuilder_widget(const config& cfg);
@ -73,8 +72,8 @@ public:
#endif
};
typedef boost::intrusive_ptr<tbuilder_widget> tbuilder_widget_ptr;
typedef boost::intrusive_ptr<const tbuilder_widget> const_tbuilder_widget_ptr;
typedef std::shared_ptr<tbuilder_widget> tbuilder_widget_ptr;
typedef std::shared_ptr<const tbuilder_widget> const_tbuilder_widget_ptr;
/**
* Registers a widget to be build.
@ -115,7 +114,7 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg);
template <class T>
tbuilder_widget_ptr build_widget(const config& cfg)
{
return new T(cfg);
return std::make_shared<T>(cfg);
}
struct tbuilder_grid : public tbuilder_widget
@ -147,8 +146,8 @@ public:
void build(tgrid& grid, const treplacements& replacements) const;
};
typedef boost::intrusive_ptr<tbuilder_grid> tbuilder_grid_ptr;
typedef boost::intrusive_ptr<const tbuilder_grid> tbuilder_grid_const_ptr;
typedef std::shared_ptr<tbuilder_grid> tbuilder_grid_ptr;
typedef std::shared_ptr<const tbuilder_grid> tbuilder_grid_const_ptr;
class twindow_builder
{

View file

@ -431,7 +431,7 @@ private:
tchat_log::tchat_log(const vconfig& cfg, replay* r) : view_()
{
LOG_CHAT_LOG << "Entering tchat_log::tchat_log" << std::endl;
view_ = std::shared_ptr<view>(new view(cfg, r));
view_ = std::make_shared<view>(cfg, r);
LOG_CHAT_LOG << "Exiting tchat_log::tchat_log" << std::endl;
}

View file

@ -577,17 +577,17 @@ public:
model_.set_inspect_window_text(
config_to_string(ai::manager::to_config(side_), "engine"));
}
if(selected == 3) {
model_.set_inspect_window_text(
config_to_string(ai::manager::to_config(side_), "stage"));
}
if(selected == 4) {
model_.set_inspect_window_text(
config_to_string(ai::manager::to_config(side_), "aspect"));
}
if(selected == 5) {
model_.set_inspect_window_text(
config_to_string(ai::manager::to_config(side_), "goal"));
@ -685,25 +685,22 @@ public:
sm_controller_ptr_vector;
controller(model& m) : model_(m), sm_controllers_()
{
sm_controllers_.push_back(std::shared_ptr<single_mode_controller>(
new variable_mode_controller("variables", model_)));
sm_controllers_.push_back(std::shared_ptr<single_mode_controller>(
new event_mode_controller(
"events", model_, event_mode_controller::EVENT_HANDLER)));
sm_controllers_.push_back(std::shared_ptr<single_mode_controller>(
new event_mode_controller(
"menu items", model_, event_mode_controller::WMI_HANDLER)));
sm_controllers_.push_back(std::shared_ptr<single_mode_controller>(
new unit_mode_controller("units", model_)));
sm_controllers_.push_back(std::make_shared<variable_mode_controller>
("variables", model_));
sm_controllers_.push_back(std::make_shared<event_mode_controller>
("events", model_, event_mode_controller::EVENT_HANDLER));
sm_controllers_.push_back(std::make_shared<event_mode_controller>
("menu items", model_, event_mode_controller::WMI_HANDLER));
sm_controllers_.push_back(std::make_shared<unit_mode_controller>
("units", model_));
// BOOST_FOREACHteam
int sides = resources::teams
? static_cast<int>((*resources::teams).size())
: 0;
for(int side = 1; side <= sides; ++side) {
std::string side_str = std::to_string(side);
sm_controllers_.push_back(std::shared_ptr<single_mode_controller>(
new team_mode_controller(
std::string("team ") + side_str, model_, side)));
sm_controllers_.push_back(std::make_shared<team_mode_controller>
(std::string("team ") + side_str, model_, side));
}
}

View file

@ -250,8 +250,8 @@ public:
side_str = font::span_color(team::get_side_color(side))
+ side_str + "</span>";
model_.add_side(side, side_str);
side_controllers_.push_back(std::shared_ptr<side_controller>(
new side_controller(side_str, model_, side)));
side_controllers_.push_back(std::make_shared<side_controller>(
side_str, model_, side));
}
}
}

View file

@ -206,7 +206,7 @@ bool tcontainer_::disable_click_dismiss() const
}
void
tcontainer_::init_grid(const boost::intrusive_ptr<tbuilder_grid>& grid_builder)
tcontainer_::init_grid(const std::shared_ptr<tbuilder_grid>& grid_builder)
{
log_scope2(log_gui_general, LOG_SCOPE_HEADER);

View file

@ -161,7 +161,7 @@ public:
*
* @param grid_builder The builder for the grid.
*/
void init_grid(const boost::intrusive_ptr<tbuilder_grid>& grid_builder);
void init_grid(const std::shared_ptr<tbuilder_grid>& grid_builder);
/***** **** ***** ***** wrappers to the grid **** ********* *****/

View file

@ -18,15 +18,13 @@
#include "widget.hpp"
#include "tstring.hpp"
#include <boost/intrusive_ptr.hpp>
typedef std::map<std::string, t_string> string_map;
namespace gui2
{
struct tbuilder_grid;
typedef boost::intrusive_ptr<const tbuilder_grid> tbuilder_grid_const_ptr;
typedef std::shared_ptr<const tbuilder_grid> tbuilder_grid_const_ptr;
class tgrid;

View file

@ -35,8 +35,8 @@ REGISTER_WIDGET(horizontal_scrollbar)
unsigned thorizontal_scrollbar::minimum_positioner_length() const
{
boost::intrusive_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = boost::dynamic_pointer_cast<const thorizontal_scrollbar_definition::
std::shared_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = std::static_pointer_cast<const thorizontal_scrollbar_definition::
tresolution>(config());
assert(conf);
@ -45,8 +45,8 @@ unsigned thorizontal_scrollbar::minimum_positioner_length() const
unsigned thorizontal_scrollbar::maximum_positioner_length() const
{
boost::intrusive_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = boost::dynamic_pointer_cast<const thorizontal_scrollbar_definition::
std::shared_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = std::static_pointer_cast<const thorizontal_scrollbar_definition::
tresolution>(config());
assert(conf);
@ -55,8 +55,8 @@ unsigned thorizontal_scrollbar::maximum_positioner_length() const
unsigned thorizontal_scrollbar::offset_before() const
{
boost::intrusive_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = boost::dynamic_pointer_cast<const thorizontal_scrollbar_definition::
std::shared_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = std::static_pointer_cast<const thorizontal_scrollbar_definition::
tresolution>(config());
assert(conf);
@ -65,8 +65,8 @@ unsigned thorizontal_scrollbar::offset_before() const
unsigned thorizontal_scrollbar::offset_after() const
{
boost::intrusive_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = boost::dynamic_pointer_cast<const thorizontal_scrollbar_definition::
std::shared_ptr<const thorizontal_scrollbar_definition::tresolution>
conf = std::static_pointer_cast<const thorizontal_scrollbar_definition::
tresolution>(config());
assert(conf);

View file

@ -138,8 +138,8 @@ void tlabel::load_config_extra()
{
assert(config());
boost::intrusive_ptr<const tlabel_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tlabel_definition::tresolution>(
std::shared_ptr<const tlabel_definition::tresolution>
conf = std::static_pointer_cast<const tlabel_definition::tresolution>(
config());
assert(conf);

View file

@ -115,7 +115,7 @@ void tlistbox::remove_row(const unsigned row, unsigned count)
width_reduced += generator_->item(row).get_width();
}
else {
height_reduced += generator_->item(row).get_height();
height_reduced += generator_->item(row).get_height();
}
}
generator_->delete_item(row);
@ -732,7 +732,7 @@ tlistbox_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -847,17 +847,17 @@ tbuilder_listbox::tbuilder_listbox(const config& cfg)
, has_maximum_(cfg["has_maximum"].to_bool(true))
{
if(const config& h = cfg.child("header")) {
header = new tbuilder_grid(h);
header = std::make_shared<tbuilder_grid>(h);
}
if(const config& f = cfg.child("footer")) {
footer = new tbuilder_grid(f);
footer = std::make_shared<tbuilder_grid>(f);
}
const config& l = cfg.child("list_definition");
VALIDATE(l, _("No list defined."));
list_builder = new tbuilder_grid(l);
list_builder = std::make_shared<tbuilder_grid>(l);
assert(list_builder);
VALIDATE(list_builder->rows == 1,
_("A 'list_definition' should contain one row."));
@ -940,8 +940,8 @@ twidget* tbuilder_listbox::build() const
DBG_GUI_G << "Window builder: placed listbox '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const tlistbox_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tlistbox_definition::tresolution>(
std::shared_ptr<const tlistbox_definition::tresolution>
conf = std::static_pointer_cast<const tlistbox_definition::tresolution>(
widget->config());
assert(conf);
@ -1024,7 +1024,7 @@ tbuilder_horizontal_listbox::tbuilder_horizontal_listbox(const config& cfg)
const config& l = cfg.child("list_definition");
VALIDATE(l, _("No list defined."));
list_builder = new tbuilder_grid(l);
list_builder = std::make_shared<tbuilder_grid>(l);
assert(list_builder);
VALIDATE(list_builder->rows == 1,
_("A 'list_definition' should contain one row."));
@ -1078,8 +1078,8 @@ twidget* tbuilder_horizontal_listbox::build() const
DBG_GUI_G << "Window builder: placed listbox '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const tlistbox_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tlistbox_definition::tresolution>(
std::shared_ptr<const tlistbox_definition::tresolution>
conf = std::static_pointer_cast<const tlistbox_definition::tresolution>(
widget->config());
assert(conf);

View file

@ -60,8 +60,8 @@ unsigned tstate_default::get_state() const
tmatrix::tmatrix(const implementation::tbuilder_matrix& builder)
: tbase(builder, get_control_type()), content_(), pane_(nullptr)
{
boost::intrusive_ptr<const tmatrix_definition::tresolution>
cfg = boost::dynamic_pointer_cast<const tmatrix_definition::tresolution>(
std::shared_ptr<const tmatrix_definition::tresolution>
cfg = std::static_pointer_cast<const tmatrix_definition::tresolution>(
config());
tbuilder_widget::treplacements replacements;
@ -286,19 +286,19 @@ tbuilder_matrix::tbuilder_matrix(const config& cfg)
, builder_main(create_builder_widget(cfg.child("main", "[matrix]")))
{
if(const config& top = cfg.child("top")) {
builder_top = new tbuilder_grid(top);
builder_top = std::make_shared<tbuilder_grid>(top);
}
if(const config& bottom = cfg.child("bottom")) {
builder_bottom = new tbuilder_grid(bottom);
builder_bottom = std::make_shared<tbuilder_grid>(bottom);
}
if(const config& left = cfg.child("left")) {
builder_left = new tbuilder_grid(left);
builder_left = std::make_shared<tbuilder_grid>(left);
}
if(const config& right = cfg.child("right")) {
builder_right = new tbuilder_grid(right);
builder_right = std::make_shared<tbuilder_grid>(right);
}
}

View file

@ -214,7 +214,7 @@ const surface tminimap::get_image(const int w, const int h) const
try
{
const gamemap map(boost::make_shared<terrain_type_data>(*terrain_), map_data_);
const gamemap map(std::make_shared<terrain_type_data>(*terrain_), map_data_);
const surface surf = image::getMinimap(w, h, map, nullptr);
cache.insert(std::make_pair(key, tvalue(surf)));
#ifdef DEBUG_MINIMAP_CACHE

View file

@ -215,7 +215,7 @@ tmulti_page_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -272,7 +272,7 @@ tbuilder_multi_page::tbuilder_multi_page(const config& cfg)
const config& page = cfg.child("page_definition");
VALIDATE(page, _("No page defined."));
builder = new tbuilder_grid(page);
builder = std::make_shared<tbuilder_grid>(page);
assert(builder);
/** @todo This part is untested. */
@ -312,9 +312,8 @@ twidget* tbuilder_multi_page::build() const
DBG_GUI_G << "Window builder: placed multi_page '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const tmulti_page_definition::tresolution>
conf = boost::
dynamic_pointer_cast<const tmulti_page_definition::tresolution>(
std::shared_ptr<const tmulti_page_definition::tresolution>
conf = std::static_pointer_cast<const tmulti_page_definition::tresolution>(
widget->config());
assert(conf);

View file

@ -36,8 +36,8 @@ REGISTER_WIDGET(panel)
SDL_Rect tpanel::get_client_rect() const
{
boost::intrusive_ptr<const tpanel_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tpanel_definition::tresolution>(
std::shared_ptr<const tpanel_definition::tresolution> conf
= std::static_pointer_cast<const tpanel_definition::tresolution>(
config());
assert(conf);
@ -76,8 +76,8 @@ void tpanel::impl_draw_foreground(surface& frame_buffer, int x_offset, int y_off
tpoint tpanel::border_space() const
{
boost::intrusive_ptr<const tpanel_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tpanel_definition::tresolution>(
std::shared_ptr<const tpanel_definition::tresolution> conf
= std::static_pointer_cast<const tpanel_definition::tresolution>(
config());
assert(conf);
@ -196,7 +196,7 @@ tbuilder_panel::tbuilder_panel(const config& cfg)
VALIDATE(c, _("No grid defined."));
grid = new tbuilder_grid(c);
grid = std::make_shared<tbuilder_grid>(c);
}
twidget* tbuilder_panel::build() const

View file

@ -188,7 +188,7 @@ tscroll_label_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -248,9 +248,8 @@ twidget* tbuilder_scroll_label::build() const
widget->set_vertical_scrollbar_mode(vertical_scrollbar_mode);
widget->set_horizontal_scrollbar_mode(horizontal_scrollbar_mode);
boost::intrusive_ptr<const tscroll_label_definition::tresolution>
conf = boost::
dynamic_pointer_cast<const tscroll_label_definition::tresolution>(
std::shared_ptr<const tscroll_label_definition::tresolution>
conf = std::static_pointer_cast<const tscroll_label_definition::tresolution>(
widget->config());
assert(conf);

View file

@ -98,7 +98,7 @@ tscrollbar_panel_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -146,7 +146,7 @@ tbuilder_scrollbar_panel::tbuilder_scrollbar_panel(const config& cfg)
const config& definition = cfg.child("definition");
VALIDATE(definition, _("No list defined."));
grid = new tbuilder_grid(definition);
grid = std::make_shared<tbuilder_grid>(definition);
assert(grid);
}
@ -162,8 +162,8 @@ twidget* tbuilder_scrollbar_panel::build() const
DBG_GUI_G << "Window builder: placed scrollbar_panel '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const tscrollbar_panel_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tscrollbar_panel_definition::
std::shared_ptr<const tscrollbar_panel_definition::tresolution> conf
= std::static_pointer_cast<const tscrollbar_panel_definition::
tresolution>(
widget->config());
assert(conf);

View file

@ -128,7 +128,7 @@ void load_widget_definitions(tgui_definition& gui_definition,
cfg.child_range(key ? key : definition_type + "_definition"))
{
definitions.push_back(new T(definition));
definitions.push_back(std::make_shared<T>(definition));
}
load_widget_definitions(gui_definition, definition_type, definitions);

View file

@ -60,8 +60,8 @@ tpoint tslider::calculate_best_size() const
if(best_slider_length_ != 0) {
// Override length.
boost::intrusive_ptr<const tslider_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tslider_definition::
std::shared_ptr<const tslider_definition::tresolution> conf
= std::static_pointer_cast<const tslider_definition::
tresolution>(config());
assert(conf);
@ -157,8 +157,8 @@ void tslider::child_callback_positioner_moved()
unsigned tslider::minimum_positioner_length() const
{
boost::intrusive_ptr<const tslider_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tslider_definition::tresolution>(
std::shared_ptr<const tslider_definition::tresolution>
conf = std::static_pointer_cast<const tslider_definition::tresolution>(
config());
assert(conf);
return conf->minimum_positioner_length;
@ -166,8 +166,8 @@ unsigned tslider::minimum_positioner_length() const
unsigned tslider::maximum_positioner_length() const
{
boost::intrusive_ptr<const tslider_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tslider_definition::tresolution>(
std::shared_ptr<const tslider_definition::tresolution>
conf = std::static_pointer_cast<const tslider_definition::tresolution>(
config());
assert(conf);
return conf->maximum_positioner_length;
@ -175,8 +175,8 @@ unsigned tslider::maximum_positioner_length() const
unsigned tslider::offset_before() const
{
boost::intrusive_ptr<const tslider_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tslider_definition::tresolution>(
std::shared_ptr<const tslider_definition::tresolution>
conf = std::static_pointer_cast<const tslider_definition::tresolution>(
config());
assert(conf);
return conf->left_offset;
@ -184,8 +184,8 @@ unsigned tslider::offset_before() const
unsigned tslider::offset_after() const
{
boost::intrusive_ptr<const tslider_definition::tresolution>
conf = boost::dynamic_pointer_cast<const tslider_definition::tresolution>(
std::shared_ptr<const tslider_definition::tresolution>
conf = std::static_pointer_cast<const tslider_definition::tresolution>(
config());
assert(conf);
return conf->right_offset;

View file

@ -199,7 +199,7 @@ tstacked_widget_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -236,7 +236,7 @@ tbuilder_stacked_widget::tbuilder_stacked_widget(const config& cfg)
VALIDATE(s, _("No stack defined."));
for(const auto & layer : s.child_range("layer"))
{
stack.push_back(new tbuilder_grid(layer));
stack.push_back(std::make_shared<tbuilder_grid>(layer));
}
}
@ -249,9 +249,8 @@ twidget* tbuilder_stacked_widget::build() const
DBG_GUI_G << "Window builder: placed stacked widget '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const tstacked_widget_definition::tresolution>
conf = boost::
dynamic_pointer_cast<const tstacked_widget_definition::tresolution>(
std::shared_ptr<const tstacked_widget_definition::tresolution>
conf = std::static_pointer_cast<const tstacked_widget_definition::tresolution>(
widget->config());
assert(conf);

View file

@ -245,8 +245,8 @@ void ttext_box::update_offsets()
{
assert(config());
boost::intrusive_ptr<const ttext_box_definition::tresolution>
conf = boost::dynamic_pointer_cast<const ttext_box_definition::tresolution>(
std::shared_ptr<const ttext_box_definition::tresolution>
conf = std::static_pointer_cast<const ttext_box_definition::tresolution>(
config());
assert(conf);
@ -328,8 +328,8 @@ void ttext_box::load_config_extra()
{
assert(config());
boost::intrusive_ptr<const ttext_box_definition::tresolution>
conf = boost::dynamic_pointer_cast<const ttext_box_definition::tresolution>(
std::shared_ptr<const ttext_box_definition::tresolution>
conf = std::static_pointer_cast<const ttext_box_definition::tresolution>(
config());
assert(conf);

View file

@ -141,8 +141,8 @@ unsigned ttoggle_panel::get_state() const
SDL_Rect ttoggle_panel::get_client_rect() const
{
boost::intrusive_ptr<const ttoggle_panel_definition::tresolution> conf
= boost::dynamic_pointer_cast<const ttoggle_panel_definition::
std::shared_ptr<const ttoggle_panel_definition::tresolution> conf
= std::static_pointer_cast<const ttoggle_panel_definition::
tresolution>(config());
assert(conf);
@ -157,8 +157,8 @@ SDL_Rect ttoggle_panel::get_client_rect() const
tpoint ttoggle_panel::border_space() const
{
boost::intrusive_ptr<const ttoggle_panel_definition::tresolution> conf
= boost::dynamic_pointer_cast<const ttoggle_panel_definition::
std::shared_ptr<const ttoggle_panel_definition::tresolution> conf
= std::static_pointer_cast<const ttoggle_panel_definition::
tresolution>(config());
assert(conf);
@ -189,8 +189,8 @@ void ttoggle_panel::set_state(const tstate state)
state_ = state;
set_is_dirty(true);
boost::intrusive_ptr<const ttoggle_panel_definition::tresolution> conf
= boost::dynamic_pointer_cast<const ttoggle_panel_definition::
std::shared_ptr<const ttoggle_panel_definition::tresolution> conf
= std::static_pointer_cast<const ttoggle_panel_definition::
tresolution>(config());
assert(conf);
}
@ -416,7 +416,7 @@ tbuilder_toggle_panel::tbuilder_toggle_panel(const config& cfg)
VALIDATE(c, _("No grid defined."));
grid = new tbuilder_grid(c);
grid = std::make_shared<tbuilder_grid>(c);
}
twidget* tbuilder_toggle_panel::build() const

View file

@ -190,7 +190,7 @@ void ttree_view::signal_handler_left_button_down(const event::tevent event)
}
template<ttree_view_node* (ttree_view_node::*func) ()>
ttree_view_node* ttree_view::get_next_node()
{
{
ttree_view_node* selected = selected_item();
if(!selected) {
return nullptr;
@ -224,7 +224,7 @@ void ttree_view::handle_key_up_arrow(SDLMod modifier, bool& handled)
handled = true;
}
else {
tscrollbar_container::handle_key_up_arrow(modifier, handled);
tscrollbar_container::handle_key_up_arrow(modifier, handled);
}
}
@ -234,7 +234,7 @@ void ttree_view::handle_key_down_arrow(SDLMod modifier, bool& handled)
handled = true;
}
else {
tscrollbar_container::handle_key_down_arrow(modifier, handled);
tscrollbar_container::handle_key_down_arrow(modifier, handled);
}
}
@ -306,7 +306,7 @@ ttree_view_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -403,9 +403,8 @@ twidget* tbuilder_tree_view::build() const
DBG_GUI_G << "Window builder: placed tree_view '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const ttree_view_definition::tresolution>
conf = boost::
dynamic_pointer_cast<const ttree_view_definition::tresolution>(
std::shared_ptr<const ttree_view_definition::tresolution>
conf = std::static_pointer_cast<const ttree_view_definition::tresolution>(
widget->config());
assert(conf);
@ -429,7 +428,7 @@ ttree_node::ttree_node(const config& cfg)
VALIDATE(node_definition, _("No node defined."));
builder = new tbuilder_grid(node_definition);
builder = std::make_shared<tbuilder_grid>(node_definition);
}
} // namespace implementation

View file

@ -245,7 +245,7 @@ tunit_preview_pane_definition::tresolution::tresolution(const config& cfg)
const config& child = cfg.child("grid");
VALIDATE(child, _("No grid defined."));
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
// }---------- BUILDER -----------{
@ -267,8 +267,8 @@ twidget* tbuilder_unit_preview_pane::build() const
DBG_GUI_G << "Window builder: placed unit preview pane '" << id
<< "' with definition '" << definition << "'.\n";
boost::intrusive_ptr<const tunit_preview_pane_definition::tresolution> conf
= boost::dynamic_pointer_cast<
std::shared_ptr<const tunit_preview_pane_definition::tresolution> conf
= std::static_pointer_cast<
const tunit_preview_pane_definition::tresolution>(widget->config());
assert(conf);

View file

@ -30,8 +30,8 @@ REGISTER_WIDGET(vertical_scrollbar)
unsigned tvertical_scrollbar::minimum_positioner_length() const
{
boost::intrusive_ptr<const tvertical_scrollbar_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tvertical_scrollbar_definition::
std::shared_ptr<const tvertical_scrollbar_definition::tresolution> conf
= std::static_pointer_cast<const tvertical_scrollbar_definition::
tresolution>(config());
assert(conf);
return conf->minimum_positioner_length;
@ -39,8 +39,8 @@ unsigned tvertical_scrollbar::minimum_positioner_length() const
unsigned tvertical_scrollbar::maximum_positioner_length() const
{
boost::intrusive_ptr<const tvertical_scrollbar_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tvertical_scrollbar_definition::
std::shared_ptr<const tvertical_scrollbar_definition::tresolution> conf
= std::static_pointer_cast<const tvertical_scrollbar_definition::
tresolution>(config());
assert(conf);
return conf->maximum_positioner_length;
@ -48,8 +48,8 @@ unsigned tvertical_scrollbar::maximum_positioner_length() const
unsigned tvertical_scrollbar::offset_before() const
{
boost::intrusive_ptr<const tvertical_scrollbar_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tvertical_scrollbar_definition::
std::shared_ptr<const tvertical_scrollbar_definition::tresolution> conf
= std::static_pointer_cast<const tvertical_scrollbar_definition::
tresolution>(config());
assert(conf);
return conf->top_offset;
@ -57,8 +57,8 @@ unsigned tvertical_scrollbar::offset_before() const
unsigned tvertical_scrollbar::offset_after() const
{
boost::intrusive_ptr<const tvertical_scrollbar_definition::tresolution> conf
= boost::dynamic_pointer_cast<const tvertical_scrollbar_definition::
std::shared_ptr<const tvertical_scrollbar_definition::tresolution> conf
= std::static_pointer_cast<const tvertical_scrollbar_definition::
tresolution>(config());
assert(conf);
return conf->bottom_offset;

View file

@ -55,7 +55,6 @@
#endif
#include "preferences.hpp"
#include "preferences_display.hpp"
#include "reference_counted_object.hpp"
#include "sdl/rect.hpp"
#include "sdl/utils.hpp"
#include "tstring.hpp"
@ -1014,8 +1013,8 @@ void twindow::layout()
{
/***** Initialize. *****/
boost::intrusive_ptr<const twindow_definition::tresolution>
conf = boost::dynamic_pointer_cast<const twindow_definition::tresolution>(
std::shared_ptr<const twindow_definition::tresolution>
conf = std::static_pointer_cast<const twindow_definition::tresolution>(
config());
assert(conf);
@ -1298,7 +1297,7 @@ void swap_grid(tgrid* grid,
} // namespace
void twindow::finalize(const boost::intrusive_ptr<tbuilder_grid>& content_grid)
void twindow::finalize(const std::shared_ptr<tbuilder_grid>& content_grid)
{
swap_grid(nullptr, &grid(), content_grid->build(), "_window_content_grid");
}
@ -1533,7 +1532,7 @@ twindow_definition::tresolution::tresolution(const config& cfg)
/** @todo Evaluate whether the grid should become mandatory. */
if(child) {
grid = new tbuilder_grid(child);
grid = std::make_shared<tbuilder_grid>(child);
}
}

View file

@ -36,7 +36,6 @@
class CVideo;
namespace boost { template <class T> class intrusive_ptr; }
namespace gui2 { class twidget; }
namespace gui2 { namespace event { struct tmessage; } }
namespace gui2 { struct tpoint; }
@ -683,7 +682,7 @@ private:
*
* @param content_grid The new contents for the content grid.
*/
void finalize(const boost::intrusive_ptr<tbuilder_grid>& content_grid);
void finalize(const std::shared_ptr<tbuilder_grid>& content_grid);
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
tdebug_layout_graph* debug_layout_;