当前位置: 首页>>代码示例>>C++>>正文


C++ QScriptEngine::deleteLater方法代码示例

本文整理汇总了C++中QScriptEngine::deleteLater方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngine::deleteLater方法的具体用法?C++ QScriptEngine::deleteLater怎么用?C++ QScriptEngine::deleteLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QScriptEngine的用法示例。


在下文中一共展示了QScriptEngine::deleteLater方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: waitFor

bool ScriptJob::waitFor( QObject *sender, const char *signal, WaitForType type )
{
    // The called function returned, but asynchronous network requests may have been started.
    // Wait for all network requests to finish, because slots in the script may get called
    const int finishWaitTime = 100;
    int finishWaitCounter = 0;

    m_mutex->lockInline();
    bool success = m_success;
    bool quit = m_quit;
    if ( !success || quit ) {
        m_mutex->unlockInline();
        return true;
    }

    QScriptEngine *engine = m_engine;
    ScriptObjects objects = m_objects;
    m_mutex->unlockInline();

    while ( finishWaitCounter < 50 && sender ) {
        if ( (type == WaitForNetwork && !objects.network->hasRunningRequests()) ||
             (type == WaitForScriptFinish && !engine->isEvaluating()) ||
             (type == WaitForNothing && finishWaitCounter > 0) )
        {
            break;
        }

        QEventLoop loop;
        connect( sender, signal, &loop, SLOT(quit()) );
        QTimer::singleShot( finishWaitTime, &loop, SLOT(quit()) );

        // Store a pointer to the event loop, to be able to quit it from the destructor
        m_mutex->lockInline();
        m_eventLoop = &loop;
        m_mutex->unlockInline();

        // Engine continues execution here / waits for a signal
        loop.exec();

        QMutexLocker locker( m_mutex );
        if ( !m_eventLoop || m_quit ) {
            // Job was aborted
            m_engine = 0;
            m_objects.clear();
            engine->deleteLater();
            return false;
        }
        m_eventLoop = 0;

        ++finishWaitCounter;
    }

    if ( finishWaitCounter >= 50 && type == WaitForScriptFinish ) {
        // Script not finished
        engine->abortEvaluation();
    }
    return finishWaitCounter < 50;
}
开发者ID:janLo,项目名称:PlansmaPublicTransport,代码行数:58,代码来源:script_thread.cpp

示例2:

ControllerEngine::~ControllerEngine() {
    // Clean up
    for (int i=0; i < kDecks; i++) {
        delete m_pitchFilter[i];
        m_pitchFilter[i] = NULL;
    }

    // Delete the script engine, first clearing the pointer so that
    // other threads will not get the dead pointer after we delete it.
    if (m_pEngine != NULL) {
        QScriptEngine *engine = m_pEngine;
        m_pEngine = NULL;
        engine->deleteLater();
    }

}
开发者ID:bkgood,项目名称:mixxx,代码行数:16,代码来源:controllerengine.cpp


注:本文中的QScriptEngine::deleteLater方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。