Skip to content

Commit

Permalink
opt: use a different way to handle the resources
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Oct 6, 2023
1 parent fe292bc commit 49d61ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/resourceschemehandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
buffer->deleteLater();
} );
}

0 comments on commit 49d61ae

Please sign in to comment.