Fix #9: Station rating popup crash
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "../tile_type.h"
|
||||
#include "../town_map.h"
|
||||
#include "../town.h"
|
||||
#include "../viewport_func.h"
|
||||
#include "../window_func.h"
|
||||
#include "../zoom_func.h"
|
||||
|
||||
@@ -485,16 +486,22 @@ public:
|
||||
{
|
||||
/* Always close tooltips when the cursor is not in our window. */
|
||||
if (!_cursor.in_window) {
|
||||
delete this;
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
switch (this->close_cond) {
|
||||
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
|
||||
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
|
||||
case TCC_RIGHT_CLICK: if (!_right_button_down) this->Close(); break;
|
||||
case TCC_HOVER: if (!_mouse_hovering) this->Close(); 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -520,12 +520,12 @@ void WatchCompany::OnInvalidateData(int data, bool gui_scope)
|
||||
}
|
||||
else if(this->Wtype == EWT_CLIENT){
|
||||
if (data == 2) {
|
||||
delete this;
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID((ClientID)this->watched_client);
|
||||
if (!ci) {
|
||||
delete this;
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -527,7 +527,7 @@ struct BuildRailToolbarWindow : Window {
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) delete this;
|
||||
if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) this->Close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user