Issue #10: Ability to cancel the operation

This commit is contained in:
Jakub Melka
2022-02-04 20:03:23 +01:00
parent 284f0c4db8
commit 49cab7937a
15 changed files with 302 additions and 61 deletions

View File

@ -64,11 +64,12 @@ void PDFAsynchronousPageCompilerWorkerThread::run()
auto proxy = m_compiler->getProxy();
proxy->getFontCache()->setCacheShrinkEnabled(this, false);
auto compilePage = [proxy](PDFAsynchronousPageCompiler::CompileTask& task) -> PDFPrecompiledPage
auto compilePage = [this, proxy](PDFAsynchronousPageCompiler::CompileTask& task) -> PDFPrecompiledPage
{
PDFPrecompiledPage compiledPage;
PDFCMSPointer cms = proxy->getCMSManager()->getCurrentCMS();
PDFRenderer renderer(proxy->getDocument(), proxy->getFontCache(), cms.data(), proxy->getOptionalContentActivity(), proxy->getFeatures(), proxy->getMeshQualitySettings());
renderer.setOperationControl(m_compiler);
renderer.compile(&task.precompiledPage, task.pageIndex);
task.finished = true;
return compiledPage;
@ -122,6 +123,11 @@ PDFAsynchronousPageCompiler::~PDFAsynchronousPageCompiler()
stop(true);
}
bool PDFAsynchronousPageCompiler::isOperationCancelled() const
{
return m_state == State::Stopping;
}
void PDFAsynchronousPageCompiler::start()
{
switch (m_state)