Esempio n. 1
0
QString TableGenerator::findComposeFile()
{
    // check if XCOMPOSEFILE points to a Compose file
    if (qEnvironmentVariableIsSet("XCOMPOSEFILE")) {
        const QString path = QFile::decodeName(qgetenv("XCOMPOSEFILE"));
        if (QFile::exists(path))
            return path;
        else
            qWarning("$XCOMPOSEFILE doesn't point to an existing file");
    }

    // check if user’s home directory has a file named .XCompose
    if (cleanState()) {
        QString path = qgetenv("HOME") + QLatin1String("/.XCompose");
        if (QFile::exists(path))
            return path;
    }

    // check for the system provided compose files
    if (cleanState()) {
        QString table = composeTableForLocale();
        if (cleanState()) {
            if (table.isEmpty())
                // no table mappings for the system's locale in the compose.dir
                m_state = UnsupportedLocale;
            else {
                QString path = QDir(systemComposeDir()).filePath(table);
                if (QFile::exists(path))
                    return path;
            }
        }
    }
    return QString();
}
void tst_qqmlenginecleanup::test_valueTypeProviderModule()
{
    // this test ensures that a module which installs a value type
    // provider can be reinitialized after multiple calls to
    // qmlClearTypeRegistrations() without causing cycles in the
    // value type provider list.
    QQmlEngine *e = 0;
    QUrl testFile1 = testFileUrl("testFile1.qml");
    QUrl testFile2 = testFileUrl("testFile2.qml");
    bool noCycles = false;
    for (int i = 0; i < 20; ++i) {
        cleanState(&e);
        QQmlComponent c(e, this);
        c.loadUrl(i % 2 == 0 ? testFile1 : testFile2); // this will hang if cycles exist.
    }
    delete e;
    e = 0;
    noCycles = true;
    QVERIFY(noCycles);

    // this test ensures that no crashes occur due to using
    // a dangling QQmlType pointer in the type compiler
    // which results from qmlClearTypeRegistrations()
    QUrl testFile3 = testFileUrl("testFile3.qml");
    bool noDangling = false;
    for (int i = 0; i < 20; ++i) {
        cleanState(&e);
        QQmlComponent c(e, this);
        c.loadUrl(i % 2 == 0 ? testFile1 : testFile3); // this will crash if dangling ptr exists.
    }
    delete e;
    noDangling = true;
    QVERIFY(noDangling);
}
Esempio n. 3
0
void TableGenerator::findComposeFile()
{
    bool found = false;
    // check if XCOMPOSEFILE points to a Compose file
    if (qEnvironmentVariableIsSet("XCOMPOSEFILE")) {
        QString composeFile(qgetenv("XCOMPOSEFILE"));
        if (composeFile.endsWith(QLatin1String("Compose")))
            found = processFile(composeFile);
        else
            qWarning("Qt Warning: XCOMPOSEFILE doesn't point to a valid Compose file");
#ifdef DEBUG_GENERATOR
        if (found)
            qDebug() << "Using Compose file from: " << composeFile;
#endif
    }
    // check if user’s home directory has a file named .XCompose
    if (!found && cleanState()) {
        QString composeFile = qgetenv("HOME") + QStringLiteral("/.XCompose");
        if (QFile(composeFile).exists())
            found = processFile(composeFile);
#ifdef DEBUG_GENERATOR
        if (found)
            qDebug() << "Using Compose file from: " << composeFile;
#endif
    }
    // check for the system provided compose files
    if (!found && cleanState()) {
        QString table = composeTableForLocale();
        if (cleanState()) {
            if (table.isEmpty())
                // no table mappings for the system's locale in the compose.dir
                m_state = UnsupportedLocale;
            else
                found = processFile(systemComposeDir() + QLatin1Char('/') + table);
#ifdef DEBUG_GENERATOR
            if (found)
                qDebug() << "Using Compose file from: " <<
                            systemComposeDir() + QLatin1Char('/') + table;
#endif
        }
    }

    if (found && m_composeTable.isEmpty())
        m_state = EmptyTable;

    if (!found)
        m_state = MissingComposeFile;
}
Esempio n. 4
0
bool FileHandle::close() {
  if (!isOpened()) {
    setState(BadBit);
    return false;
  }

  if (isOwned()) {
    if (::close(m_Handler) == -1) {
      setState(FailBit);
      return false;
    }
  }

  m_Path.native().clear();
  m_Size = 0;
  m_OpenMode = OpenMode(NotOpen);
  cleanState();
  return true;
}
Esempio n. 5
0
void nodeDock::added()
{
    connect( app(), SIGNAL(entityAdded(AEntity*)), this, SLOT(centreNode(AEntity*)) );
    connect( app(), SIGNAL(entityRemoved(AEntity*)), this, SLOT(removeNode(AEntity*)) );
    connect( app(), SIGNAL(entityRemoved(AEntity*)), this, SLOT(entityRemoved(AEntity*)) );

    connect( app(), SIGNAL(selectionChanged()), this, SLOT(appSelectionChanged()) );
    connect( app(), SIGNAL(insertState()), this, SLOT(rebuildGui()) );
    connect( app(), SIGNAL(cleanState()), this, SLOT(rebuildGui()) );
    connect( app(), SIGNAL(openState()), this, SLOT(rebuildGui()) );
    connect( app(), SIGNAL(workingPathChanged()), this, SLOT(rebuildGui()) );

    mView->setApp(app());

    mScene->addItem( new propertiesWidget( app(), mView ) );

    qRegisterMetaType<AEntityLocation>();

    directoryListing *dir( new directoryListing( app(), mView ) );
    mScene->addItem( dir );
    connect( dir, SIGNAL(changeDirectory(AEntityLocation)), this, SLOT(changeDirectory(AEntityLocation)), Qt::QueuedConnection );
}
Esempio n. 6
0
TableGenerator::TableGenerator() : m_state(NoErrors),
    m_systemComposeDir(QString())
{
    initPossibleLocations();
    QString composeFilePath = findComposeFile();
#ifdef DEBUG_GENERATOR
// don't use cache when in debug mode.
    if (!composeFilePath.isEmpty())
        qDebug() << "Using Compose file from: " << composeFilePath;
#else
    QComposeCacheFileHeader fileInfo = readFileMetadata(composeFilePath);
    if (fileInfo.fileSize != 0)
        m_composeTable = loadCache(fileInfo);
#endif
    if (m_composeTable.isEmpty() && cleanState()) {
        if (composeFilePath.isEmpty()) {
            m_state = MissingComposeFile;
        } else {
            QFile composeFile(composeFilePath);
            composeFile.open(QIODevice::ReadOnly);
            parseComposeFile(&composeFile);
            orderComposeTable();
            if (m_composeTable.isEmpty()) {
                m_state = EmptyTable;
#ifndef DEBUG_GENERATOR
// don't save cache when in debug mode
            } else {
                fileInfo.cacheVersion = SupportedCacheVersion;
                saveCache(fileInfo, m_composeTable);
#endif
            }
        }
    }
#ifdef DEBUG_GENERATOR
    printComposeTable();
#endif
}