本文整理汇总了C++中QScriptEngine::collectGarbage方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngine::collectGarbage方法的具体用法?C++ QScriptEngine::collectGarbage怎么用?C++ QScriptEngine::collectGarbage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptEngine
的用法示例。
在下文中一共展示了QScriptEngine::collectGarbage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void tst_QScriptString::test()
{
QScriptEngine eng;
{
QScriptString str;
QVERIFY(!str.isValid());
QVERIFY(str == str);
QVERIFY(!(str != str));
QVERIFY(str.toString().isNull());
QScriptString str1(str);
QVERIFY(!str1.isValid());
QScriptString str2 = str;
QVERIFY(!str2.isValid());
QCOMPARE(str.toArrayIndex(), quint32(0xffffffff));
}
for (int x = 0; x < 2; ++x) {
QString ciao = QString::fromLatin1("ciao");
QScriptString str = eng.toStringHandle(ciao);
QVERIFY(str.isValid());
QVERIFY(str == str);
QVERIFY(!(str != str));
QCOMPARE(str.toString(), ciao);
QScriptString str1(str);
QCOMPARE(str, str1);
QScriptString str2 = str;
QCOMPARE(str, str2);
QScriptString str3 = eng.toStringHandle(ciao);
QVERIFY(str3.isValid());
QCOMPARE(str, str3);
eng.collectGarbage();
QVERIFY(str.isValid());
QCOMPARE(str.toString(), ciao);
QVERIFY(str1.isValid());
QCOMPARE(str1.toString(), ciao);
QVERIFY(str2.isValid());
QCOMPARE(str2.toString(), ciao);
QVERIFY(str3.isValid());
QCOMPARE(str3.toString(), ciao);
}
{
QScriptEngine* eng2 = new QScriptEngine;
QString one = QString::fromLatin1("one");
QString two = QString::fromLatin1("two");
QScriptString oneInterned = eng2->toStringHandle(one);
QCOMPARE(oneInterned.toString(), one);
QScriptString twoInterned = eng2->toStringHandle(two);
QCOMPARE(twoInterned.toString(), two);
QVERIFY(oneInterned != twoInterned);
QVERIFY(!(oneInterned == twoInterned));
delete eng2;
}
}