mail[Wesnoth-commits] r28579 - /trunk/src/gui/widgets/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on August 14, 2008 - 18:14:
Author: mordante
Date: Thu Aug 14 18:03:37 2008
New Revision: 28579

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28579&view=rev
Log:
Valgrid discovered some memory leaks.  The reference_counted objects aren't
stored in a intrusive_ptr so don't cleanup themselves.

This commit fixes tresolution_ and subclasses.

Modified:
    trunk/src/gui/widgets/control.hpp
    trunk/src/gui/widgets/panel.cpp
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp
    trunk/src/gui/widgets/slider.cpp
    trunk/src/gui/widgets/text_box.cpp
    trunk/src/gui/widgets/toggle_panel.cpp
    trunk/src/gui/widgets/vertical_scrollbar.cpp
    trunk/src/gui/widgets/window.cpp
    trunk/src/gui/widgets/window_builder.cpp

Modified: trunk/src/gui/widgets/control.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.hpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.hpp (original)
+++ trunk/src/gui/widgets/control.hpp Thu Aug 14 18:03:37 2008
@@ -181,10 +181,10 @@
                { assert(index < canvas_.size()); return canvas_[index]; }
 
 protected:
-       tresolution_definition_* config() { return config_; }
-       const tresolution_definition_* config() const { return config_; }
-
-       void set_config(tresolution_definition_* config) { config_ = config; }
+       tresolution_definition_ptr config() { return config_; }
+       tresolution_definition_const_ptr config() const { return config_; }
+
+       void set_config(tresolution_definition_ptr config) { config_ = 
config; }
 
        /***** ***** ***** ***** miscellaneous ***** ***** ***** *****/
 
@@ -282,7 +282,7 @@
         * on the resolution widgets can look different, use different fonts.
         * Windows can use extra scrollbars use abbreviations as text etc.
         */
-       tresolution_definition_* config_;
+       tresolution_definition_ptr config_;
 
        /**
         * Load class dependant config settings.

Modified: trunk/src/gui/widgets/panel.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/panel.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/panel.cpp (original)
+++ trunk/src/gui/widgets/panel.cpp Thu Aug 14 18:03:37 2008
@@ -40,8 +40,8 @@
 
 SDL_Rect tpanel::get_client_rect() const
 {
-       const tpanel_definition::tresolution* conf = 
-               dynamic_cast<const tpanel_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tpanel_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tpanel_definition::tresolution>(config());
        assert(conf);
 
        SDL_Rect result = get_rect();
@@ -71,8 +71,8 @@
 
 tpoint tpanel::border_space() const
 {
-       const tpanel_definition::tresolution* conf = 
-               dynamic_cast<const tpanel_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tpanel_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tpanel_definition::tresolution>(config());
        assert(conf);
 
        return tpoint(conf->left_border + conf->right_border,

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Thu Aug 14 18:03:37 2008
@@ -1063,7 +1063,8 @@
        DBG_G_P << "Parsing window " << id << '\n';
 }
 
-tresolution_definition_* get_control(const std::string& control_type, const 
std::string& definition)
+tresolution_definition_ptr get_control(
+               const std::string& control_type, const std::string& 
definition)
 {
        const tgui_definition::tcontrol_definition_map::const_iterator  
                control_definition = 
current_gui->second.control_definition.find(control_type);
@@ -1080,7 +1081,7 @@
                assert(control != control_definition->second.end());
        }
 
-       for(std::vector<tresolution_definition_*>::const_iterator 
+       for(std::vector<tresolution_definition_ptr>::const_iterator 
                        itor = (*control->second).resolutions.begin(),
                        end = (*control->second).resolutions.end();
                        itor != end;

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Thu Aug 14 18:03:37 2008
@@ -97,6 +97,14 @@
        std::vector<tstate_definition> state;
 };
 
+typedef 
+       boost::intrusive_ptr<tresolution_definition_> 
+       tresolution_definition_ptr;
+
+typedef 
+       boost::intrusive_ptr<const tresolution_definition_> 
+       tresolution_definition_const_ptr;
+
 struct tcontrol_definition : public reference_counted_object
 {
 private:
@@ -111,7 +119,7 @@
        std::string id;
        t_string description;
 
-       std::vector<tresolution_definition_*> resolutions;
+       std::vector<tresolution_definition_ptr> resolutions;
 
 };
 
@@ -336,7 +344,7 @@
        unsigned double_click_time_;
 };
 
-       tresolution_definition_* get_control(
+       tresolution_definition_ptr get_control(
                const std::string& control_type, const std::string& 
definition);
 
        std::vector<twindow_builder::tresolution>::const_iterator 

Modified: trunk/src/gui/widgets/slider.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/slider.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/slider.cpp (original)
+++ trunk/src/gui/widgets/slider.cpp Thu Aug 14 18:03:37 2008
@@ -123,8 +123,8 @@
        }
 
        // Override length.
-       const tslider_definition::tresolution* conf = 
-               dynamic_cast<const 
tslider_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tslider_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tslider_definition::tresolution>(config());
        assert(conf); 
 
        size.x = conf->left_offset + best_slider_length_ + conf->right_offset;
@@ -149,32 +149,32 @@
 
 unsigned tslider::minimum_positioner_length() const
 { 
-       const tslider_definition::tresolution* conf = 
-               dynamic_cast<const 
tslider_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tslider_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tslider_definition::tresolution>(config());
        assert(conf); 
        return conf->minimum_positioner_length; 
 }
 
 unsigned tslider::maximum_positioner_length() const
 {
-       const tslider_definition::tresolution* conf = 
-               dynamic_cast<const 
tslider_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tslider_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tslider_definition::tresolution>(config());
        assert(conf); 
        return conf->maximum_positioner_length; 
 }
 
 unsigned tslider::offset_before() const
 { 
-       const tslider_definition::tresolution* conf = 
-               dynamic_cast<const 
tslider_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tslider_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tslider_definition::tresolution>(config());
        assert(conf); 
        return conf->left_offset; 
 }
 
 unsigned tslider::offset_after() const
 { 
-       const tslider_definition::tresolution* conf = 
-               dynamic_cast<const 
tslider_definition::tresolution*>(config());
+       boost::intrusive_ptr<const tslider_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tslider_definition::tresolution>(config());
        assert(conf); 
        return conf->right_offset; 
 }

Modified: trunk/src/gui/widgets/text_box.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text_box.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/text_box.cpp (original)
+++ trunk/src/gui/widgets/text_box.cpp Thu Aug 14 18:03:37 2008
@@ -313,8 +313,8 @@
 {
        assert(config());
 
-       ttext_box_definition::tresolution* conf = 
-               dynamic_cast<ttext_box_definition::tresolution*>(config());
+       boost::intrusive_ptr<const ttext_box_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
ttext_box_definition::tresolution>(config());
        assert(conf);
 
        text_height_ = font::get_max_height(conf->text_font_size);

Modified: trunk/src/gui/widgets/toggle_panel.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/toggle_panel.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/toggle_panel.cpp (original)
+++ trunk/src/gui/widgets/toggle_panel.cpp Thu Aug 14 18:03:37 2008
@@ -121,8 +121,8 @@
 
 SDL_Rect ttoggle_panel::get_client_rect() const
 {
-       const ttoggle_panel_definition::tresolution* conf = 
-               dynamic_cast<const 
ttoggle_panel_definition::tresolution*>(config());
+       boost::intrusive_ptr<const ttoggle_panel_definition::tresolution> 
conf =
+               boost::dynamic_pointer_cast<const 
ttoggle_panel_definition::tresolution>(config());
        assert(conf);
 
        SDL_Rect result = get_rect();
@@ -136,8 +136,8 @@
 
 tpoint ttoggle_panel::border_space() const
 {
-       const ttoggle_panel_definition::tresolution* conf = 
-               dynamic_cast<const 
ttoggle_panel_definition::tresolution*>(config());
+       boost::intrusive_ptr<const ttoggle_panel_definition::tresolution> 
conf =
+               boost::dynamic_pointer_cast<const 
ttoggle_panel_definition::tresolution>(config());
        assert(conf);
 
        return tpoint(conf->left_border + conf->right_border,
@@ -176,8 +176,8 @@
        state_ = state;
        set_dirty(true);
 
-       const ttoggle_panel_definition::tresolution* conf = 
-               dynamic_cast<const 
ttoggle_panel_definition::tresolution*>(config());
+       boost::intrusive_ptr<const ttoggle_panel_definition::tresolution> 
conf =
+               boost::dynamic_pointer_cast<const 
ttoggle_panel_definition::tresolution>(config());
        assert(conf);
 
        if(conf->state_change_full_redraw) {

Modified: trunk/src/gui/widgets/vertical_scrollbar.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/vertical_scrollbar.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/vertical_scrollbar.cpp (original)
+++ trunk/src/gui/widgets/vertical_scrollbar.cpp Thu Aug 14 18:03:37 2008
@@ -44,32 +44,32 @@
 
 unsigned tvertical_scrollbar::minimum_positioner_length() const
 { 
-       const tvertical_scrollbar_definition::tresolution* conf = 
-               dynamic_cast<const 
tvertical_scrollbar_definition::tresolution*>(config());
+       boost::intrusive_ptr<const 
tvertical_scrollbar_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tvertical_scrollbar_definition::tresolution>(config());
        assert(conf); 
        return conf->minimum_positioner_length; 
 }
 
 unsigned tvertical_scrollbar::maximum_positioner_length() const
 { 
-       const tvertical_scrollbar_definition::tresolution* conf = 
-               dynamic_cast<const 
tvertical_scrollbar_definition::tresolution*>(config());
+       boost::intrusive_ptr<const 
tvertical_scrollbar_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tvertical_scrollbar_definition::tresolution>(config());
        assert(conf); 
        return conf->maximum_positioner_length; 
 }
 
 unsigned tvertical_scrollbar::offset_before() const
 { 
-       const tvertical_scrollbar_definition::tresolution* conf = 
-               dynamic_cast<const 
tvertical_scrollbar_definition::tresolution*>(config());
+       boost::intrusive_ptr<const 
tvertical_scrollbar_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tvertical_scrollbar_definition::tresolution>(config());
        assert(conf); 
        return conf->top_offset; 
 }
 
 unsigned tvertical_scrollbar::offset_after() const
 { 
-       const tvertical_scrollbar_definition::tresolution* conf = 
-               dynamic_cast<const 
tvertical_scrollbar_definition::tresolution*>(config());
+       boost::intrusive_ptr<const 
tvertical_scrollbar_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tvertical_scrollbar_definition::tresolution>(config());
        assert(conf); 
        return conf->bottom_offset; 
 }

Modified: trunk/src/gui/widgets/window.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Thu Aug 14 18:03:37 2008
@@ -231,8 +231,8 @@
 
 SDL_Rect twindow::get_client_rect() const
 {
-       const twindow_definition::tresolution* conf = 
-               dynamic_cast<const 
twindow_definition::tresolution*>(config());
+       boost::intrusive_ptr<const twindow_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
twindow_definition::tresolution>(config());
        assert(conf);
 
        SDL_Rect result = get_rect();

Modified: trunk/src/gui/widgets/window_builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=28579&r1=28578&r2=28579&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Thu Aug 14 18:03:37 2008
@@ -706,7 +706,8 @@
        DBG_G << "Window builder: placed listbox '" << id << "' with 
defintion '" 
                << definition << "'.\n";
 
-       tlistbox_definition::tresolution* conf = 
static_cast<tlistbox_definition::tresolution*>(listbox->config());
+       boost::intrusive_ptr<const tlistbox_definition::tresolution> conf =
+               boost::dynamic_pointer_cast<const 
tlistbox_definition::tresolution>(listbox->config());
        assert(conf);
 
        tgrid* scrollbar = dynamic_cast<tgrid*>(conf->scrollbar->build());




Related Messages


Powered by MHonArc, Updated Thu Aug 14 19:02:50 2008