コード例 #1
0
ファイル: qtopianamespace.cpp プロジェクト: GuoMarvin/qtmoko
/*
  Cache all the path look-up in a singleton so it only has to be done once
  per process.  Previous implementations also did this, but lets make it
  thread-safe while we're on the job.
*/
QtopiaPathHelper *QtopiaPathHelper::instance()
{
    static QtopiaPathHelper ph;
    static QAtomicInt initialized(0);

    if ( initialized.testAndSetOrdered( 0, 1 ))
    {
        QChar sl = QDir::separator();
        const char *d = getenv("QTOPIA_PATH");
        if ( d ) {
            ph.installPaths = QString(d).split(":");
            for (QStringList::Iterator it=ph.installPaths.begin(); it!=ph.installPaths.end(); ++it) {
                if ( (*it)[(*it).length()-1] != sl )
                    (*it) += sl;
            }
        }

        // The installation directory is always searched before QTOPIA_PATH
        ph.prefixPath = QLibraryInfo::location(QLibraryInfo::PrefixPath);
        if ( ph.prefixPath[ph.prefixPath.length()-1] != sl )
            ph.prefixPath += sl;
        ph.installPaths.prepend(ph.prefixPath);

        // System update directory is always searched first
        ph.setUpdatePath();
        QString up = ph.updatePath;
        if ( !up.isEmpty() )
            ph.installPaths.prepend(up);

        // Package paths are last
        ph.setPackagePath();
        QString pp = ph.packagePath;
        if ( !pp.isEmpty() )
            ph.installPaths.append( pp );
        QDir::root().mkpath( pp + "/pics" );
        QDir::root().mkpath( pp + "/sounds" );

        initialized = 2;
    }
    else
    {
        while ( initialized != 2 )
            Qtopia::msleep( 5 );
    }

    return &ph;
}
コード例 #2
0
void myMessageOutput(QtMsgType type, const char *msg)
{
    QString strMsg = QString::fromLatin1(msg);

    if (!QCoreApplication::closingDown()) {
        if (!logger.isNull()) {
            if (recursiveLock.testAndSetOrdered(0, 1)) {
                QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
                recursiveLock = 0;
            }
        } else {
            warnings += strMsg;
            warnings += QLatin1Char('\n');
        }
    }
    if (systemMsgOutput) { // Windows
        systemMsgOutput(type, msg);
    } else { // Unix
        fprintf(stderr, "%s\n", msg);
        fflush(stderr);
    }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Suneal/qt
void myMessageOutput(QtMsgType type, const char *msg)
{
    QString strMsg = QString::fromLatin1(msg);

    if (!QCoreApplication::closingDown()) {
        if (!logger.isNull()) {
            if (recursiveLock.testAndSetOrdered(0, 1)) {
                QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
                recursiveLock = 0;
            }
        } else {
            warnings += strMsg;
            warnings += QLatin1Char('\n');
        }
    }
#if defined (Q_OS_SYMBIAN)
    static int fd = -1;
    if (fd == -1)
        fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT);

    ::write(fd, msg, strlen(msg));
    ::write(fd, "\n", 1);
    ::fsync(fd);
    switch (type) {
    case QtFatalMsg:
        abort();
    }
#endif

    if (systemMsgOutput) {
        systemMsgOutput(type, msg);
    } else { // Unix
        fprintf(stderr, "%s\n", msg);
        fflush(stderr);
    }
}