Fix #9: Station rating popup crash

This commit is contained in:
dP
2021-10-03 23:00:15 +03:00
parent 0f31dce938
commit f1f6bea47d
3 changed files with 13 additions and 6 deletions

View File

@@ -14,6 +14,7 @@
#include "../tile_type.h" #include "../tile_type.h"
#include "../town_map.h" #include "../town_map.h"
#include "../town.h" #include "../town.h"
#include "../viewport_func.h"
#include "../window_func.h" #include "../window_func.h"
#include "../zoom_func.h" #include "../zoom_func.h"
@@ -485,16 +486,22 @@ public:
{ {
/* Always close tooltips when the cursor is not in our window. */ /* Always close tooltips when the cursor is not in our window. */
if (!_cursor.in_window) { if (!_cursor.in_window) {
delete this; this->Close();
return; return;
} }
/* We can show tooltips while dragging tools. These are shown as long as /* We can show tooltips while dragging tools. These are shown as long as
* we are dragging the tool. Normal tooltips work with hover or rmb. */ * we are dragging the tool. Normal tooltips work with hover or rmb. */
switch (this->close_cond) { switch (this->close_cond) {
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break; case TCC_RIGHT_CLICK: if (!_right_button_down) this->Close(); break;
case TCC_HOVER: if (!_mouse_hovering) delete this; break; case TCC_HOVER: if (!_mouse_hovering) this->Close(); break;
case TCC_NONE: break; case TCC_NONE: break;
case TCC_EXIT_VIEWPORT: {
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) this->Close();
break;
}
} }
} }
}; };

View File

@@ -520,12 +520,12 @@ void WatchCompany::OnInvalidateData(int data, bool gui_scope)
} }
else if(this->Wtype == EWT_CLIENT){ else if(this->Wtype == EWT_CLIENT){
if (data == 2) { if (data == 2) {
delete this; this->Close();
return; return;
} }
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID((ClientID)this->watched_client); NetworkClientInfo *ci = NetworkClientInfo::GetByClientID((ClientID)this->watched_client);
if (!ci) { if (!ci) {
delete this; this->Close();
return; return;
} }
else { else {

View File

@@ -527,7 +527,7 @@ struct BuildRailToolbarWindow : Window {
{ {
if (!gui_scope) return; if (!gui_scope) return;
if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) delete this; if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) this->Close();
} }
/** /**