mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #11732 from IntelOrca/fix/11730-11731
Fix #11730, 11731: invalid read / write in plugin code
This commit is contained in:
commit
70f3b9cd8e
|
@ -232,6 +232,7 @@ void CustomListView::SetScrollbars(ScrollbarType value, bool initialising)
|
|||
}
|
||||
}
|
||||
window_init_scroll_widgets(ParentWindow);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +248,10 @@ void CustomListView::SetColumns(const std::vector<ListViewColumn>& columns, bool
|
|||
LastKnownSize = {};
|
||||
SortItems(0, ColumnSortOrder::None);
|
||||
if (!initialising)
|
||||
{
|
||||
window_init_scroll_widgets(ParentWindow);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<ListViewItem>& CustomListView::CustomListView::GetItems() const
|
||||
|
@ -261,7 +265,10 @@ void CustomListView::SetItems(const std::vector<ListViewItem>& items, bool initi
|
|||
Items = items;
|
||||
SortItems(0, ColumnSortOrder::None);
|
||||
if (!initialising)
|
||||
{
|
||||
window_update_scroll_widgets(ParentWindow);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomListView::SetItems(std::vector<ListViewItem>&& items, bool initialising)
|
||||
|
@ -269,7 +276,10 @@ void CustomListView::SetItems(std::vector<ListViewItem>&& items, bool initialisi
|
|||
Items = items;
|
||||
SortItems(0, ColumnSortOrder::None);
|
||||
if (!initialising)
|
||||
{
|
||||
window_init_scroll_widgets(ParentWindow);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomListView::SortItem(size_t indexA, size_t indexB, int32_t column)
|
||||
|
@ -317,7 +327,11 @@ void CustomListView::SortItems(int32_t column, ColumnSortOrder order)
|
|||
|
||||
CurrentSortOrder = order;
|
||||
CurrentSortColumn = column;
|
||||
Columns[column].SortOrder = order;
|
||||
if (column >= 0 && static_cast<size_t>(column) < Columns.size())
|
||||
{
|
||||
Columns[column].SortOrder = order;
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void CustomListView::Resize(const ScreenSize& size)
|
||||
|
@ -376,6 +390,7 @@ void CustomListView::Resize(const ScreenSize& size)
|
|||
}
|
||||
|
||||
window_init_scroll_widgets(ParentWindow);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
ScreenSize CustomListView::GetSize()
|
||||
|
@ -420,6 +435,7 @@ void CustomListView::MouseOver(const ScreenCoordsXY& pos, bool isMouseDown)
|
|||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
scriptEngine.ExecutePluginCall(Owner, OnHighlight, { dukRow, dukColumn }, false);
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,6 +445,7 @@ void CustomListView::MouseOver(const ScreenCoordsXY& pos, bool isMouseDown)
|
|||
if (hitResult && hitResult->Row == HEADER_ROW)
|
||||
{
|
||||
ColumnHeaderPressedCurrentState = (hitResult->Column == ColumnHeaderPressed);
|
||||
Invalidate();
|
||||
}
|
||||
IsMouseDown = true;
|
||||
}
|
||||
|
@ -452,6 +469,7 @@ void CustomListView::MouseDown(const ScreenCoordsXY& pos)
|
|||
if (CanSelect)
|
||||
{
|
||||
SelectedCell = hitResult;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
auto ctx = OnClick.context();
|
||||
|
@ -469,6 +487,7 @@ void CustomListView::MouseDown(const ScreenCoordsXY& pos)
|
|||
{
|
||||
ColumnHeaderPressed = hitResult->Column;
|
||||
ColumnHeaderPressedCurrentState = true;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
IsMouseDown = true;
|
||||
|
@ -485,8 +504,12 @@ void CustomListView::MouseUp(const ScreenCoordsXY& pos)
|
|||
}
|
||||
}
|
||||
|
||||
ColumnHeaderPressed = std::nullopt;
|
||||
ColumnHeaderPressedCurrentState = false;
|
||||
if (!ColumnHeaderPressedCurrentState)
|
||||
{
|
||||
ColumnHeaderPressed = std::nullopt;
|
||||
ColumnHeaderPressedCurrentState = false;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomListView::Paint(rct_window* w, rct_drawpixelinfo* dpi, const rct_scroll* scroll) const
|
||||
|
@ -680,4 +703,9 @@ std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& po
|
|||
return result;
|
||||
}
|
||||
|
||||
void CustomListView::Invalidate()
|
||||
{
|
||||
ParentWindow->Invalidate();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -145,6 +145,7 @@ namespace OpenRCT2::Ui::Windows
|
|||
rct_drawpixelinfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text,
|
||||
bool isHighlighted) const;
|
||||
std::optional<RowColumn> GetItemIndexAt(const ScreenCoordsXY& pos);
|
||||
void Invalidate();
|
||||
};
|
||||
} // namespace OpenRCT2::Ui::Windows
|
||||
|
||||
|
|
|
@ -53,21 +53,37 @@ namespace OpenRCT2::Scripting
|
|||
|
||||
int32_t x_get() const
|
||||
{
|
||||
return GetWindow()->windowPos.x;
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
return w->windowPos.x;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void x_set(int32_t value)
|
||||
{
|
||||
auto w = GetWindow();
|
||||
window_set_position(w, { value, w->windowPos.y });
|
||||
if (w != nullptr)
|
||||
{
|
||||
window_set_position(w, { value, w->windowPos.y });
|
||||
}
|
||||
}
|
||||
int32_t y_get() const
|
||||
{
|
||||
return GetWindow()->windowPos.y;
|
||||
auto w = GetWindow();
|
||||
if (w != nullptr)
|
||||
{
|
||||
return w->windowPos.y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void y_set(int32_t value)
|
||||
{
|
||||
auto w = GetWindow();
|
||||
window_set_position(w, { w->windowPos.x, value });
|
||||
if (w != nullptr)
|
||||
{
|
||||
window_set_position(w, { w->windowPos.x, value });
|
||||
}
|
||||
}
|
||||
int32_t width_get() const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue