mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-06 06:50:07 +00:00
Possible fix for crash in Window::limitPosition() when parent is nullptr (fix #4261)
We cannot reproduce this but just adding a check here to avoid using a nullptr parent pointer.
This commit is contained in:
parent
00894101e0
commit
9d69cb8dfe
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -765,12 +765,17 @@ void Window::limitSize(gfx::Size& size)
|
||||
|
||||
void Window::limitPosition(gfx::Rect& rect)
|
||||
{
|
||||
auto parent = this->parent();
|
||||
ASSERT(parent);
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
if (rect.y < 0) {
|
||||
rect.y = 0;
|
||||
rect.h = bounds().h;
|
||||
}
|
||||
auto titlebarH = childrenBounds().y - bounds().y;
|
||||
auto limitB = parent()->bounds().y2() - titlebarH;
|
||||
auto limitB = parent->bounds().y2() - titlebarH;
|
||||
if (rect.y > limitB) {
|
||||
rect.y = limitB;
|
||||
rect.h = bounds().h;
|
||||
@ -781,7 +786,7 @@ void Window::limitPosition(gfx::Rect& rect)
|
||||
rect.x = limitL;
|
||||
rect.w = bounds().w;
|
||||
}
|
||||
auto limitR = parent()->bounds().x2() - border().right();
|
||||
auto limitR = parent->bounds().x2() - border().right();
|
||||
if (rect.x > limitR) {
|
||||
rect.x = limitR;
|
||||
rect.w = bounds().w;
|
||||
|
Loading…
Reference in New Issue
Block a user