即使对于本地html文件加载,LoadFinished也为false

时间:2012-11-15 14:11:06

标签: macos qt qwebview qwebkit

我们开发了一个" .app"使用C ++ / QT的MAC OSX安装程序。即使在加载来自本地文件系统的html文件时,我们也面临着间歇性地调用loadFinished信号的问题。

我发现了一些关于loadFinished信号被多次调用的其他帖子。在我的情况下,信号只用false调用一次。

有人遇到过这种问题吗?依赖loadProgress信号值100可以吗?

QT - 4.8.2
Mac OS X - 10.7

代码段: -

boost::scoped_ptr<QWebView> m_webViewP;
static const boost::filesystem::path kJSEntryPoint = boost::filesystem::path("web") / boost::filesystem::path("index.html");

QUrl fileURL(QString::fromStdString(ISettingsManager::getInstance()->getJSEntryPoint()));
Log(INFO, "Loading auth page[%s].", qPrintable(fileURL.toString()));
m_webViewP->load(fileURL);
m_webViewP->activateWindow();
m_webViewP->raise();


const std::string SettingsManagerImpl::getJSEntryPoint() const
{
    boost::filesystem::path retPath;

    retPath = getAppDir_();

    retPath /= kJSEntryPoint;
    std::string toRet = retPath.string();
    convertToURL_(toRet);

    return toRet;
}


void SettingsManagerImpl::convertToURL_(std::string &path) const
{
    size_t index = path.find(kBackSlash);
    while (index != std::string::npos)
    {
        path.replace(index, 1, kForwarSlash);
        index = path.find(kBackSlash);
    }

    path = kURLPrefix + path;
}   

boost::filesystem::path SettingsManagerImpl::getAppDir_() const
{
#ifdef _WIN32
    TCHAR pathName[MAX_PATH];
    if (::GetModuleFileName(NULL, pathName, MAX_PATH) == 0)
    {
        SSLog(ERROR, "Error while retrieving app path.");
        return "";
    }

    ::PathRemoveFileSpec(pathName);

    return boost::filesystem::path(pathName);
#else
    NSAutoreleasePool *poolP = [[NSAutoreleasePool alloc] init];

    NSString *pathP = [[NSBundle mainBundle] executablePath];
    pathP = [pathP stringByDeletingLastPathComponent];

    boost::filesystem::path toRet([pathP cStringUsingEncoding:NSASCIIStringEncoding]);

    [poolP drain];
    return toRet;
#endif
}

0 个答案:

没有答案