Commit efd35bb0 authored by Lukáš Tvrdý's avatar Lukáš Tvrdý

Fix memory leak when loading presets

==7314== 814,368 (768 direct, 813,600 indirect) bytes in 48 blocks are definitely lost in loss record 134,421 of 134,446
==7314==    at 0x4A06965: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7314==    by 0x592A37C: KisPaintOpPreset::load() (kis_paintop_preset.cpp:177)
==7314==    by 0x4FBED34: KoResourceServer<KisPaintOpPreset, SharedPointerStroragePolicy<KisSharedPtr<KisPaintOpPreset> > >::loadResources(QStringList) (KoResourceServer.h:194)
==7314==    by 0x5DD9AD5: KoResourceLoaderThread::run() (KoResourceServerProvider.cpp:140)
==7314==    by 0x3DD7E7C69E: ??? (in /usr/lib64/libQtCore.so.4.8.6)
==7314==    by 0x35D1A07EE4: start_thread (in /usr/lib64/libpthread-2.18.so)
==7314==    by 0x35D16F4D1C: clone (in /usr/lib64/libc-2.18.so)
parent 337013b1
......@@ -91,7 +91,7 @@ KisPaintOpPresetSP KisPaintOpPreset::clone() const
}
void KisPaintOpPreset::setPresetDirty(bool value)
{
m_d->dirtyPreset = value;
m_d->dirtyPreset = value;
}
bool KisPaintOpPreset::isPresetDirty() const
{
......@@ -174,9 +174,14 @@ bool KisPaintOpPreset::load()
resourceStore->close();
}
else {
dev = new QFile(filename());
if (dev->size() == 0)
{
delete dev;
return false;
}
if (dev->size() == 0) return false;
if (!dev->open(QIODevice::ReadOnly)) {
warnKrita << "Can't open file " << filename();
delete dev;
......@@ -185,6 +190,8 @@ bool KisPaintOpPreset::load()
}
bool res = loadFromDevice(dev);
delete dev;
setValid(res);
setPresetDirty(false);
return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment