mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Fix memory leak with IntEntry popups
This commit is contained in:
parent
60a4ebf8f6
commit
c6e3ca0d8b
@ -171,7 +171,7 @@ void IntEntry::openPopup()
|
|||||||
{
|
{
|
||||||
m_slider.setValue(getValue());
|
m_slider.setValue(getValue());
|
||||||
|
|
||||||
m_popupWindow = new TransparentPopupWindow(PopupWindow::ClickBehavior::CloseOnClickInOtherWindow);
|
m_popupWindow = std::make_unique<TransparentPopupWindow>(PopupWindow::ClickBehavior::CloseOnClickInOtherWindow);
|
||||||
m_popupWindow->setAutoRemap(false);
|
m_popupWindow->setAutoRemap(false);
|
||||||
m_popupWindow->addChild(&m_slider);
|
m_popupWindow->addChild(&m_slider);
|
||||||
m_popupWindow->Close.connect(&IntEntry::onPopupClose, this);
|
m_popupWindow->Close.connect(&IntEntry::onPopupClose, this);
|
||||||
@ -200,8 +200,7 @@ void IntEntry::closePopup()
|
|||||||
removeSlider();
|
removeSlider();
|
||||||
|
|
||||||
m_popupWindow->closeWindow(nullptr);
|
m_popupWindow->closeWindow(nullptr);
|
||||||
delete m_popupWindow;
|
m_popupWindow.reset();
|
||||||
m_popupWindow = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +222,7 @@ void IntEntry::onPopupClose(CloseEvent& ev)
|
|||||||
void IntEntry::removeSlider()
|
void IntEntry::removeSlider()
|
||||||
{
|
{
|
||||||
if (m_popupWindow &&
|
if (m_popupWindow &&
|
||||||
m_slider.parent() == m_popupWindow) {
|
m_slider.parent() == m_popupWindow.get()) {
|
||||||
m_popupWindow->removeChild(&m_slider);
|
m_popupWindow->removeChild(&m_slider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
|
// Copyright (C) 2022 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -11,6 +12,8 @@
|
|||||||
#include "ui/entry.h"
|
#include "ui/entry.h"
|
||||||
#include "ui/slider.h"
|
#include "ui/slider.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
class CloseEvent;
|
class CloseEvent;
|
||||||
@ -43,7 +46,7 @@ namespace ui {
|
|||||||
int m_min;
|
int m_min;
|
||||||
int m_max;
|
int m_max;
|
||||||
Slider m_slider;
|
Slider m_slider;
|
||||||
PopupWindow* m_popupWindow;
|
std::unique_ptr<PopupWindow> m_popupWindow;
|
||||||
bool m_changeFromSlider;
|
bool m_changeFromSlider;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user