Merge lp:~widelands-dev/widelands/bug-1690519-playercolor into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8363
Proposed branch: lp:~widelands-dev/widelands/bug-1690519-playercolor
Merge into: lp:widelands
Diff against target: 69 lines (+7/-7)
3 files modified
src/graphic/animation.cc (+4/-4)
src/graphic/animation.h (+1/-1)
src/graphic/playercolor.cc (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1690519-playercolor
Reviewer Review Type Date Requested Status
Klaus Halfmann copilles, test, codereview Approve
Review via email: mp+324053@code.launchpad.net

Commit message

Create playercolor unique_ptr as late as possible.

Description of the change

I am assuming that some of the rashes are due to the changes in playercolor caused by this merge:

https://code.launchpad.net/~widelands-dev/widelands/fh1_width_and_mapobject_messages/+merge/318189

So I'm hoping that this change will help.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 2196. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/232399748.
Appveyor build 2031. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1690519_playercolor-2031.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Will compile this and try the MallocMagic, but his will need some time ....

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Sorry, I tried this with:

MallocGuardEdges=y
MallocStackLoggingNoCompact=y
export MallocScribble=y
export MallocCheckHeapStart=0
export MallocCheckHeapEach=100

but before I was able to open the Mutiplayer settings it already crashes
here:

VM Regions Near 0xfffffffffffffe1e:
--> shared memory 00007fffffe12000-00007fffffe13000 [ 4K] r-x/r-x SM=SHM

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_malloc.dylib 0x00007fff8f0c0657 szone_check_all + 3160
1 libsystem_malloc.dylib 0x00007fff8f0c4149 malloc_zone_check + 58
2 libsystem_malloc.dylib 0x00007fff8f0c3ea2 internal_check + 17
3 libsystem_malloc.dylib 0x00007fff8f0b5f3b free + 358
4 widelands 0x000000010fa65c32 EditorDecreaseHeightTool::~EditorDecreaseHeightTool() + 34 (sp_counted_impl.hpp:127)
5 widelands 0x000000010fa65cab boost::detail::sp_counted_base::destroy() + 43 (sp_counted_base_clang.hpp:93)
6 widelands 0x000000010fa65e59 boost::detail::sp_counted_base::weak_release() + 57 (sp_counted_base_clang.hpp:128)
7 widelands 0x000000010fa65df2 boost::detail::sp_counted_base::release() + 66 (sp_counted_base_clang.hpp:115)
8 widelands 0x000000010fa65d8a boost::detail::shared_count::~shared_count() + 42 (shared_count.hpp:467)
9 widelands 0x000000010fa65a25 boost::detail::shared_count::~shared_count() + 21 (shared_count.hpp:471)
10 widelands 0x000000010fa3e229 boost::shared_ptr<boost::re_detail::named_subexpressions>::~shared_ptr() + 25 (shared_ptr.hpp:756)
11 widelands 0x000000010fa3e125 boost::shared_ptr<boost::re_detail::named_subexpressions>::~shared_ptr() + 21 (shared_ptr.hpp:756)

SirVers Idea of nonunique usage of a unique ptr souns reassonalbe, can we trace such cases,
maybe I should dive more into the definition of this unique ptr thingees.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Now I'm confused. Why on Earth do the multiplayer settings have anything to do with an editor tool?

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Mhh, I will need to attach a debbuger to track this down and the
next week are packed with stuff we should do, sigh.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I played this for quite a while now (with rare Malloc checks) and got no crash.

The change looks straight foreward.

So this should go in, anyone else?

Had no time for that really long debug session.

review: Approve (copilles, test, codereview)
Revision history for this message
GunChleoc (gunchleoc) wrote :

Let's get this in trunk, since it can't do any harm. Thanks for the review and test :)

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/graphic/animation.cc'
2--- src/graphic/animation.cc 2017-05-13 13:14:29 +0000
3+++ src/graphic/animation.cc 2017-05-15 11:41:00 +0000
4@@ -72,7 +72,7 @@
5 float scale) const override;
6 uint16_t nr_frames() const override;
7 uint32_t frametime() const override;
8- std::unique_ptr<const Image> representative_image(const RGBColor* clr) const override;
9+ const Image* representative_image(const RGBColor* clr) const override;
10 const std::string& representative_image_filename() const override;
11 virtual void blit(uint32_t time,
12 const Rectf& source_rect,
13@@ -219,7 +219,7 @@
14 return frametime_;
15 }
16
17-std::unique_ptr<const Image> NonPackedAnimation::representative_image(const RGBColor* clr) const {
18+const Image* NonPackedAnimation::representative_image(const RGBColor* clr) const {
19 assert(!image_files_.empty());
20 const Image* image = (hasplrclrs_ && clr) ? playercolor_image(*clr, image_files_[0]) :
21 g_gr->images().get(image_files_[0]);
22@@ -228,7 +228,7 @@
23 const int h = image->height();
24 Texture* rv = new Texture(w / scale_, h / scale_);
25 rv->blit(Rectf(0, 0, w / scale_, h / scale_), *image, Rectf(0, 0, w, h), 1., BlendMode::Copy);
26- return std::unique_ptr<const Image>(rv);
27+ return rv;
28 }
29
30 // TODO(GunChleoc): This is only here for the font renderers.
31@@ -335,7 +335,7 @@
32 const auto hash = std::make_pair(id, clr);
33 if (representative_images_.count(hash) != 1) {
34 representative_images_.insert(std::make_pair(
35- hash, std::move(g_gr->animations().get_animation(id).representative_image(clr))));
36+ hash, std::unique_ptr<const Image>(std::move(g_gr->animations().get_animation(id).representative_image(clr)))));
37 }
38 return representative_images_.at(hash).get();
39 }
40
41=== modified file 'src/graphic/animation.h'
42--- src/graphic/animation.h 2017-05-03 07:24:06 +0000
43+++ src/graphic/animation.h 2017-05-15 11:41:00 +0000
44@@ -80,7 +80,7 @@
45 /// An image of the first frame, blended with the given player color.
46 /// The 'clr' is the player color used for blending - the parameter can be
47 /// 'nullptr', in which case the neutral image will be returned.
48- virtual std::unique_ptr<const Image> representative_image(const RGBColor* clr) const = 0;
49+ virtual const Image* representative_image(const RGBColor* clr) const = 0;
50 /// The filename of the image used for the first frame, without player color.
51 virtual const std::string& representative_image_filename() const = 0;
52
53
54=== modified file 'src/graphic/playercolor.cc'
55--- src/graphic/playercolor.cc 2017-04-28 06:47:01 +0000
56+++ src/graphic/playercolor.cc 2017-05-15 11:41:00 +0000
57@@ -48,10 +48,10 @@
58 const Image* color_mask = g_gr->images().get(color_mask_filename);
59 const int w = image->width();
60 const int h = image->height();
61- auto pc_image = std::unique_ptr<Texture>(new Texture(w, h));
62+ Texture* pc_image = new Texture(w, h);
63 pc_image->fill_rect(Rectf(0, 0, w, h), RGBAColor(0, 0, 0, 0));
64 pc_image->blit_blended(Rectf(0, 0, w, h), *image, *color_mask, Rectf(0, 0, w, h), clr);
65- g_gr->images().insert(hash, std::move(pc_image));
66+ g_gr->images().insert(hash, std::unique_ptr<const Texture>(std::move(pc_image)));
67 assert(g_gr->images().has(hash));
68 return g_gr->images().get(hash);
69 }

Subscribers

People subscribed via source and target branches

to status/vote changes: