[calligra] krita: Fix memory leak in the preset proxy system
Boudewijn Rempt
boud at valdyas.org
Sat Nov 1 08:40:49 UTC 2014
Git commit 0006aa0b2be423ab2c512574aa42df70c55dfa25 by Boudewijn Rempt.
Committed on 01/11/2014 at 08:39.
Pushed by rempt into branch 'master'.
Fix memory leak in the preset proxy system
CCMAIL:kimageshop at kde.org
Please test... This should fix a memory leak and preset tweak weirdnesses
M +7 -10 krita/image/brushengine/kis_locked_properties_proxy.cpp
M +0 -12 krita/image/brushengine/kis_locked_properties_proxy.h
M +7 -5 krita/ui/kis_paintop_box.cc
M +9 -13 krita/ui/kis_paintop_options_widget.cpp
http://commits.kde.org/calligra/0006aa0b2be423ab2c512574aa42df70c55dfa25
diff --git a/krita/image/brushengine/kis_locked_properties_proxy.cpp b/krita/image/brushengine/kis_locked_properties_proxy.cpp
index ca3db4d..1d81f95 100644
--- a/krita/image/brushengine/kis_locked_properties_proxy.cpp
+++ b/krita/image/brushengine/kis_locked_properties_proxy.cpp
@@ -19,30 +19,29 @@
#include "kis_locked_properties_proxy.h"
KisLockedPropertiesProxy ::KisLockedPropertiesProxy()
+ : m_lockedProperties(0)
+ , m_parent(0)
{
- m_lockedProperties = NULL;
- m_parent = NULL;
-
}
+
KisLockedPropertiesProxy::KisLockedPropertiesProxy(KisLockedProperties* p)
{
m_lockedProperties = p;
-
}
+
KisLockedPropertiesProxy::KisLockedPropertiesProxy(const KisPropertiesConfiguration *p, KisLockedProperties *l)
{
m_lockedProperties = l;
m_parent = p;
-
}
+
QVariant KisLockedPropertiesProxy::getProperty(const QString &name) const
{
KisPropertiesConfiguration* temp = const_cast<KisPropertiesConfiguration*>(m_parent);
KisPaintOpSettings* t = dynamic_cast<KisPaintOpSettings*>(temp);
- bool saveDirtyState = false;
if (t->preset()) {
- t->preset()->isPresetDirty();
+ bool saveDirtyState = t->preset()->isPresetDirty();
if (m_lockedProperties->lockedProperties()) {
if (m_lockedProperties->lockedProperties()->hasProperty(name)) {
@@ -67,6 +66,7 @@ QVariant KisLockedPropertiesProxy::getProperty(const QString &name) const
}
return m_parent->getProperty(name);
}
+
void KisLockedPropertiesProxy::setProperty(const QString & name, const QVariant & value)
{
KisPropertiesConfiguration* temp = const_cast<KisPropertiesConfiguration*>(m_parent);
@@ -83,12 +83,9 @@ void KisLockedPropertiesProxy::setProperty(const QString & name, const QVariant
t->preset()->setPresetDirty(saveDirtyState);
return;
}
-
-
}
}
t->setProperty(name, value);
-
}
diff --git a/krita/image/brushengine/kis_locked_properties_proxy.h b/krita/image/brushengine/kis_locked_properties_proxy.h
index a1e2ac2..052dd20 100644
--- a/krita/image/brushengine/kis_locked_properties_proxy.h
+++ b/krita/image/brushengine/kis_locked_properties_proxy.h
@@ -33,9 +33,6 @@
* Whenever the user selects the option of going back to the previous configuration of the preset or "unlocks" an option -- these settings are restored
* and the settings with the "_previous" suffix are destroyed.
*/
-
-
-
class KisLockedPropertiesServer;
class KisLockedPropertiesProxy: public KisPropertiesConfiguration
@@ -48,18 +45,9 @@ public:
QVariant getProperty(const QString &name) const;
using KisPropertiesConfiguration::setProperty;
void setProperty(const QString & name, const QVariant & value);
-
-
-
-
-
-
-
private:
KisLockedProperties* m_lockedProperties;
const KisPropertiesConfiguration* m_parent;
-
-
};
#endif // KIS_LOCKED_PROPERTIES_PROXY_H
diff --git a/krita/ui/kis_paintop_box.cc b/krita/ui/kis_paintop_box.cc
index 188165e..1584627 100644
--- a/krita/ui/kis_paintop_box.cc
+++ b/krita/ui/kis_paintop_box.cc
@@ -820,17 +820,19 @@ void KisPaintopBox::sliderChanged(int n)
if (m_resourceProvider->currentPreset()->settings()->hasProperty("FlowValue"))
m_resourceProvider->currentPreset()->settings()->setProperty("FlowValue", flow);
- KisLockedPropertiesProxy *p = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(m_resourceProvider->currentPreset()->settings());
- p->setProperty("OpacityValue", opacity);
- p->setProperty("FlowValue", flow);
+ KisLockedPropertiesProxy *propertiesProxy = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(m_resourceProvider->currentPreset()->settings());
+ propertiesProxy->setProperty("OpacityValue", opacity);
+ propertiesProxy->setProperty("FlowValue", flow);
+ delete propertiesProxy;
m_optionWidget->setConfiguration(m_resourceProvider->currentPreset()->settings().data());
} else m_resourceProvider->setOpacity(opacity);
m_optionWidget->blockSignals(false);
if (m_presetsEnabled) {
m_optionWidget->setConfiguration(m_resourceProvider->currentPreset()->settings().data());
- KisLockedPropertiesProxy *p = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(m_resourceProvider->currentPreset()->settings());
- p->setProperty("OpacityValue", opacity);
+ KisLockedPropertiesProxy *propertiesProxy = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(m_resourceProvider->currentPreset()->settings());
+ propertiesProxy->setProperty("OpacityValue", opacity);
+ delete propertiesProxy;
}
if (!m_dirtyPresetsEnabled) {
m_resourceProvider->currentPreset()->setPresetDirty(false);
diff --git a/krita/ui/kis_paintop_options_widget.cpp b/krita/ui/kis_paintop_options_widget.cpp
index 0d065c9..3f870d8 100644
--- a/krita/ui/kis_paintop_options_widget.cpp
+++ b/krita/ui/kis_paintop_options_widget.cpp
@@ -103,16 +103,14 @@ void KisPaintOpOptionsWidget::addPaintOpOption(KisPaintOpOption * option)
void KisPaintOpOptionsWidget::setConfiguration(const KisPropertiesConfiguration * config)
{
Q_ASSERT(!config->getString("paintop").isEmpty());
- KisLockedPropertiesProxy* m = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(config);
+ KisLockedPropertiesProxy* propertiesProxy = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(config);
int indexcount = 0;
- foreach(KisPaintOpOption* option, m_d->paintOpOptions) {
- option->readOptionSetting(m);
- if(KisLockedPropertiesServer::instance()->propertiesFromLocked())
- {
+ foreach (KisPaintOpOption* option, m_d->paintOpOptions) {
+ option->readOptionSetting(propertiesProxy);
+ if (KisLockedPropertiesServer::instance()->propertiesFromLocked()) {
option->setLocked(true);
}
- else
- {
+ else {
option->setLocked(false);
}
@@ -125,18 +123,16 @@ void KisPaintOpOptionsWidget::setConfiguration(const KisPropertiesConfiguration
m_d->model->signalDataChanged(m_d->model->indexOf(info));
indexcount++;
}
-
+ delete propertiesProxy;
}
void KisPaintOpOptionsWidget::writeConfiguration(KisPropertiesConfiguration *config) const
{
- KisLockedPropertiesProxy* m = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(config);
+ KisLockedPropertiesProxy* propertiesProxy = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(config);
foreach(const KisPaintOpOption* option, m_d->paintOpOptions) {
- option->writeOptionSetting(m);
-
-
+ option->writeOptionSetting(propertiesProxy);
}
-
+ delete propertiesProxy;
}
void KisPaintOpOptionsWidget::setImage(KisImageWSP image)
More information about the kimageshop
mailing list