diff --git a/src/resourceschemehandler.cc b/src/resourceschemehandler.cc index ddb1cc8ce0..1d8a9d715a 100644 --- a/src/resourceschemehandler.cc +++ b/src/resourceschemehandler.cc @@ -37,11 +37,19 @@ void ResourceSchemeHandler::replyJob( sptr< Dictionary::DataRequest > reply, } QByteArray * ba = new QByteArray( data.data(), data.size() ); QBuffer * buffer = new QBuffer( ba ); - buffer->setParent( requestJob ); buffer->open( QIODeviceBase::ReadOnly ); buffer->seek( 0 ); // Reply segment requestJob->reply( content_type.toLatin1(), buffer ); + + connect( requestJob, + &QObject::destroyed, + buffer, + [&ba, &buffer]() { + ba->clear(); + delete ba; + delete buffer; + } ); }