widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #11777
[Merge] lp:~widelands-dev/widelands/fix_invalid_memory_access_on_dismantle into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/fix_invalid_memory_access_on_dismantle into lp:widelands.
Commit message:
Check if our window is dying before investigating a building note.
Patch by Klaus Halfmann.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1733812 in widelands: "Deallocated Memory on teardown of Military site"
https://bugs.launchpad.net/widelands/+bug/1733812
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fix_invalid_memory_access_on_dismantle/+merge/334428
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix_invalid_memory_access_on_dismantle into lp:widelands.
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2017-09-10 18:17:55 +0000
+++ src/wui/buildingwindow.cc 2017-11-29 08:03:01 +0000
@@ -66,6 +66,11 @@
}
void BuildingWindow::on_building_note(const Widelands::NoteBuilding& note) {
+ if (is_dying_) {
+ // Our building is potentially already destroyed. And we do not care
+ // about anything anymore anyways.
+ return;
+ }
if (note.serial == building_.serial()) {
switch (note.action) {
// The building's state has changed
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2017-08-19 23:24:28 +0000
+++ src/wui/productionsitewindow.cc 2017-11-29 08:03:01 +0000
@@ -47,7 +47,12 @@
worker_caps_(nullptr) {
productionsitenotes_subscriber_ = Notifications::subscribe<Widelands::NoteBuilding>(
[this](const Widelands::NoteBuilding& note) {
- if (note.serial == building().serial() && !is_dying_) {
+ if (is_dying_) {
+ // Our building is potentially already destroyed. And we do not care
+ // about anything anymore anyways.
+ return;
+ }
+ if (note.serial == building().serial()) {
switch (note.action) {
case Widelands::NoteBuilding::Action::kWorkersChanged:
update_worker_table();
Follow ups