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