widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06791
[Merge] lp:~widelands-dev/widelands/memleaks-and-uninit-vars into lp:widelands
Miroslav Remák has proposed merging lp:~widelands-dev/widelands/memleaks-and-uninit-vars into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/memleaks-and-uninit-vars/+merge/289561
This also fixes a crash where a leaked remnant of the game session would still be subscribed to the 'changed resolution' event if a savegame failed to load.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/memleaks-and-uninit-vars into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2016-02-18 16:14:09 +0000
+++ src/editor/editorinteractive.cc 2016-03-19 11:51:31 +0000
@@ -617,7 +617,7 @@
void EditorInteractive::run_editor(const std::string& filename, const std::string& script_to_run) {
Widelands::EditorGameBase egbase(nullptr);
- EditorInteractive eia(egbase);
+ EditorInteractive & eia = *new EditorInteractive(egbase);
egbase.set_ibase(&eia); // TODO(unknown): get rid of this
{
UI::ProgressWindow loader_ui("images/loadscreens/editor.jpg");
=== modified file 'src/graphic/texture.cc'
--- src/graphic/texture.cc 2016-03-14 19:49:52 +0000
+++ src/graphic/texture.cc 2016-03-19 11:51:31 +0000
@@ -100,6 +100,7 @@
} // namespace
Texture::Texture(int w, int h)
+ : owns_texture_(false)
{
init(w, h);
@@ -113,6 +114,7 @@
}
Texture::Texture(SDL_Surface * surface, bool intensity)
+ : owns_texture_(false)
{
init(surface->w, surface->h);
@@ -151,13 +153,13 @@
SDL_FreeSurface(surface);
}
-Texture::Texture(const GLuint texture, const Rect& subrect, int parent_w, int parent_h) {
+Texture::Texture(const GLuint texture, const Rect& subrect, int parent_w, int parent_h)
+ : owns_texture_(false)
+{
if (parent_w == 0 || parent_h == 0) {
throw wexception("Created a sub Texture with zero height and width parent.");
}
- owns_texture_ = false;
-
blit_data_ = BlitData {
texture,
parent_w, parent_h,
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2016-03-08 15:21:41 +0000
+++ src/logic/editor_game_base.cc 2016-03-19 11:51:31 +0000
@@ -145,6 +145,9 @@
return tribes_.get();
}
+void EditorGameBase::set_ibase(InteractiveBase* const b) {
+ ibase_.reset(b);
+}
InteractiveGameBase* EditorGameBase::get_igbase()
{
=== modified file 'src/logic/editor_game_base.h'
--- src/logic/editor_game_base.h 2015-11-28 22:29:26 +0000
+++ src/logic/editor_game_base.h 2016-03-19 11:51:31 +0000
@@ -153,7 +153,7 @@
return gametime_;
}
InteractiveBase* get_ibase() const {
- return ibase_;
+ return ibase_.get();
}
// safe system for storing pointers to non-MapObject C++ objects
@@ -180,9 +180,7 @@
uint32_t& get_gametime_pointer() {
return gametime_;
}
- void set_ibase(InteractiveBase* const b) {
- ibase_ = b;
- }
+ void set_ibase(InteractiveBase* const b);
/// Lua frontend, used to run Lua scripts
virtual LuaInterface& lua() {
@@ -255,7 +253,7 @@
std::unique_ptr<World> world_;
std::unique_ptr<Tribes> tribes_;
- InteractiveBase* ibase_;
+ std::unique_ptr<InteractiveBase> ibase_;
Map* map_;
uint32_t lasttrackserial_;
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2016-03-10 15:00:32 +0000
+++ src/logic/game.cc 2016-03-19 11:51:31 +0000
@@ -555,7 +555,6 @@
g_sound_handler.change_music("menu", 1000, 0);
cleanup_objects();
- delete get_ibase();
set_ibase(nullptr);
state_ = gs_notrunning;
=== modified file 'src/logic/game_settings.h'
--- src/logic/game_settings.h 2016-02-06 11:11:24 +0000
+++ src/logic/game_settings.h 2016-03-19 11:51:31 +0000
@@ -81,8 +81,9 @@
multiplayer(false),
savegame(false)
{
+ std::unique_ptr<LuaInterface> lua(new LuaInterface);
std::unique_ptr<LuaTable> win_conditions(
- (new LuaInterface)->run_script("scripting/win_conditions/init.lua"));
+ lua->run_script("scripting/win_conditions/init.lua"));
for (const int key : win_conditions->keys<int>()) {
std::string filename = win_conditions->get_string(key);
if (g_fs->file_exists(filename)) {
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2016-03-08 15:21:41 +0000
+++ src/network/nethost.cc 2016-03-19 11:51:31 +0000
@@ -715,8 +715,8 @@
try {
std::unique_ptr<UI::ProgressWindow> loader_ui;
- GameTips * tips = nullptr;
loader_ui.reset(new UI::ProgressWindow("images/loadscreens/progress.png"));
+
std::vector<std::string> tipstext;
tipstext.push_back("general_game");
tipstext.push_back("multiplayer");
@@ -724,7 +724,7 @@
tipstext.push_back(d->hp.get_players_tribe());
} catch (GameSettingsProvider::NoTribe) {
}
- tips = new GameTips(*loader_ui, tipstext);
+ std::unique_ptr<GameTips> tips(new GameTips(*loader_ui, tipstext));
loader_ui->step(_("Preparing game"));
@@ -776,8 +776,6 @@
"",
false, "nethost");
- delete tips;
-
// if this is an internet game, tell the metaserver that the game is done.
if (internet_)
InternetGaming::ref().set_game_done();
@@ -791,6 +789,7 @@
disconnect_client(0, "SERVER_CRASHED");
reaper();
}
+
throw;
}
d->game = nullptr;
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2016-03-02 17:11:16 +0000
+++ src/ui_basic/button.cc 2016-03-19 11:51:31 +0000
@@ -48,6 +48,7 @@
enabled_ (init_enabled),
repeating_ (false),
flat_ (flat),
+ keep_image_size_(false),
draw_flat_background_(false),
time_nextact_ (0),
title_ (title_text),
=== modified file 'src/ui_basic/icon.cc'
--- src/ui_basic/icon.cc 2016-02-03 18:09:15 +0000
+++ src/ui_basic/icon.cc 2016-03-19 11:51:31 +0000
@@ -30,7 +30,8 @@
const Image* picture_id)
:
Panel(parent, x, y, w, h),
- pic_(picture_id)
+ pic_(picture_id),
+ draw_frame_(false)
{
set_handle_mouse(false);
set_thinks(false);
Follow ups