diff --git a/CMakeLists.txt b/CMakeLists.txt index 424dabbb2..f6fd27450 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,16 +343,6 @@ if (KF5JS_FOUND) core/script/kjs_ocg.cpp ) target_link_libraries(okularcore PRIVATE KF5::JS KF5::JSApi) - set(CMAKE_REQUIRED_LIBRARIES KF5::JSApi) - check_cxx_source_compiles(" -#include -int main() -{ - KJSInterpreter *ip = 0; - ip->setTimeoutTime(0); - return 0; -} -" HAVE_KJS_TIMEOUT) endif() set_target_properties(okularcore PROPERTIES VERSION 9.0.0 SOVERSION 9 OUTPUT_NAME Okular5Core EXPORT_NAME Core) diff --git a/config-okular.h.cmake b/config-okular.h.cmake index c55f6530d..905aac9cb 100644 --- a/config-okular.h.cmake +++ b/config-okular.h.cmake @@ -6,6 +6,3 @@ /* Defines whether the malloc_trim method from malloc.h is available */ #cmakedefine01 HAVE_MALLOC_TRIM - -/* Defines if we have timeout support in the KJS library */ -#cmakedefine HAVE_KJS_TIMEOUT 1 diff --git a/core/script/executor_kjs.cpp b/core/script/executor_kjs.cpp index 3d32268ca..28c94bc95 100644 --- a/core/script/executor_kjs.cpp +++ b/core/script/executor_kjs.cpp @@ -10,6 +10,7 @@ #include "executor_kjs_p.h" +#include #include #include #include @@ -61,7 +62,7 @@ void ExecutorKJSPrivate::initTypes() m_docObject = JSDocument::wrapDocument( m_doc ); m_interpreter = new KJSInterpreter( m_docObject ); -#ifdef HAVE_KJS_TIMEOUT +#if KJS_VERSION > QT_VERSION_CHECK(5, 71, 0) m_interpreter->setTimeoutTime( 2000 ); // max 2 secs allowed #endif KJSContext *ctx = m_interpreter->globalContext(); @@ -117,12 +118,12 @@ void ExecutorKJS::execute( const QString &script, Event *event ) d->m_docObject.setProperty( ctx, QStringLiteral("event"), event ? JSEvent::wrapEvent( ctx, event ) : KJSUndefined() ); -#ifdef HAVE_KJS_TIMEOUT +#if KJS_VERSION > QT_VERSION_CHECK(5, 71, 0) d->m_interpreter->startTimeoutCheck(); #endif KJSResult result = d->m_interpreter->evaluate( QStringLiteral("okular.js"), 1, script, &d->m_docObject ); -#ifdef HAVE_KJS_TIMEOUT +#if KJS_VERSION > QT_VERSION_CHECK(5, 71, 0) d->m_interpreter->stopTimeoutCheck(); #endif diff --git a/core/script/kjs_app.cpp b/core/script/kjs_app.cpp index 529d0489a..aa49450ea 100644 --- a/core/script/kjs_app.cpp +++ b/core/script/kjs_app.cpp @@ -10,6 +10,7 @@ #include "kjs_app_p.h" +#include #include #include #include @@ -239,14 +240,14 @@ static KJSObject appAlert( KJSContext *context, void *, } -#ifdef HAVE_KJS_TIMEOUT +#if KJS_VERSION > QT_VERSION_CHECK(5, 71, 0) // halt timeout until the user has responded context->interpreter().stopTimeoutCheck(); #endif int button = box.exec(); -#ifdef HAVE_KJS_TIMEOUT +#if KJS_VERSION > QT_VERSION_CHECK(5, 71, 0) // restart max allowed time context->interpreter().startTimeoutCheck(); #endif