Merge remote-tracking branch 'origin/3.0'

This commit is contained in:
Eike Ziller
2013-11-29 16:36:13 +01:00
17 changed files with 5872 additions and 1636 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -298,7 +298,6 @@ int main(int argc, char **argv)
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
// QML is unusable with the xlib backend
QApplication::setGraphicsSystem(QLatin1String("raster"));
qputenv("QSG_RENDER_LOOP", "basic"); // workaround for QTBUG-35143
#endif
SharedTools::QtSingleApplication app((QLatin1String(appNameC)), argc, argv);

View File

@@ -137,6 +137,12 @@ public:
void setVariadic(bool isVariadic)
{ f._variadic = isVariadic; }
bool isPredefined() const
{ return f._predefined; }
void setPredefined(bool isPredefined)
{ f._predefined = isPredefined; }
QString toString() const;
QString toStringWithLineBreaks() const;
@@ -151,6 +157,7 @@ private:
unsigned _hidden: 1;
unsigned _functionLike: 1;
unsigned _variadic: 1;
unsigned _predefined: 1;
};
QByteArray _name;

View File

@@ -906,7 +906,51 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
{
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
Macro *macro = m_env->resolve(tk->asByteArrayRef());
static const QByteArray ppLine("__LINE__");
static const QByteArray ppFile("__FILE__");
static const QByteArray ppDate("__DATE__");
static const QByteArray ppTime("__TIME__");
ByteArrayRef macroNameRef = tk->asByteArrayRef();
if (macroNameRef.size() == 8
&& macroNameRef[0] == '_'
&& macroNameRef[1] == '_') {
PPToken newTk;
QByteArray txt;
if (macroNameRef == ppLine) {
txt = QByteArray::number(tk->lineno);
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppFile) {
txt.append('"');
txt.append(m_env->currentFileUtf8);
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppDate) {
txt.append('"');
txt.append(QDate::currentDate().toString().toUtf8());
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppTime) {
txt.append('"');
txt.append(QTime::currentTime().toString().toUtf8());
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
}
if (newTk.hasSource()) {
Macro macro;
macro.setName(macroNameRef.toByteArray());
macro.setFileName(m_env->currentFile);
macro.setPredefined(true);
macro.setDefinition(txt, QVector<PPToken>() << newTk);
m_env->bind(macro);
if (m_client)
m_client->macroAdded(macro);
}
}
Macro *macro = m_env->resolve(macroNameRef);
if (!macro
|| (tk->expanded()
&& m_state.m_tokenBuffer

View File

@@ -797,10 +797,12 @@ const Macro *CPPEditorWidget::findCanonicalMacro(const QTextCursor &cursor, Docu
if (const Macro *macro = doc->findMacroDefinitionAt(line)) {
QTextCursor macroCursor = cursor;
const QByteArray name = identifierUnderCursor(&macroCursor).toLatin1();
if (macro->name() == name)
if (macro->name() == name && !macro->isPredefined())
return macro;
} else if (const Document::MacroUse *use = doc->findMacroUseAt(cursor.position())) {
return &use->macro();
const Macro &macro = use->macro();
if (!macro.isPredefined())
return &macro;
}
return 0;

View File

@@ -592,11 +592,13 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
m_widget->showPreProcessorWidget();
} else if (fileName != CppModelManagerInterface::configurationFileName()) {
const Macro &macro = use->macro();
if (!macro.isPredefined()) {
link.targetFileName = macro.fileName();
link.targetLine = macro.line();
link.linkTextStart = use->begin();
link.linkTextEnd = use->end();
}
}
return link;
}

View File

@@ -558,6 +558,8 @@ restart_search:
usages.clear();
foreach (const Document::MacroUse &use, doc->macroUses()) {
const Macro &useMacro = use.macro();
if (useMacro.isPredefined())
continue;
if (useMacro.fileName() == macro.fileName()) { // Check if this is a match, but possibly against an outdated document.
if (source.isEmpty())

View File

@@ -58,6 +58,9 @@ QFuture<TextEditor::HighlightingResult> CppHighlightingSupportInternal::highligh
// Get macro definitions
foreach (const CPlusPlus::Macro& macro, doc->definedMacros()) {
if (macro.isPredefined())
continue; // No "real" definition location
int line, column;
editor()->convertPosition(macro.offset(), &line, &column);
++column; //Highlighting starts at (column-1) --> compensate here

View File

@@ -37,6 +37,8 @@
namespace Debugger {
namespace Internal {
const int AbiRole = Qt::UserRole + 2;
static QList<QStandardItem *> describeItem(const DebuggerItem &item)
{
QList<QStandardItem *> row;
@@ -44,7 +46,7 @@ static QList<QStandardItem *> describeItem(const DebuggerItem &item)
row.append(new QStandardItem(item.command().toUserOutput()));
row.append(new QStandardItem(item.engineTypeName()));
row.at(0)->setData(item.id());
row.at(0)->setData(item.abiNames(), Qt::UserRole + 2);
row.at(0)->setData(item.abiNames(), AbiRole);
row.at(0)->setEditable(false);
row.at(1)->setEditable(false);
row.at(1)->setData(item.toMap());
@@ -158,7 +160,7 @@ bool DebuggerItemModel::updateDebuggerStandardItem(const DebuggerItem &item, boo
QFont font = sitem->font();
font.setBold(changed);
parent->child(row, 0)->setData(item.displayName(), Qt::DisplayRole);
parent->child(row, 0)->setData(item.abiNames(), Qt::UserRole + 2);
parent->child(row, 0)->setData(item.abiNames(), AbiRole);
parent->child(row, 0)->setFont(font);
parent->child(row, 1)->setData(item.command().toUserOutput(), Qt::DisplayRole);
parent->child(row, 1)->setFont(font);
@@ -178,7 +180,7 @@ DebuggerItem DebuggerItemModel::debuggerItem(QStandardItem *sitem) const
item.m_id = i->data();
item.setDisplayName(i->data(Qt::DisplayRole).toString());
QStringList abis = i->data(Qt::UserRole + 2).toStringList();
QStringList abis = i->data(AbiRole).toStringList();
QList<ProjectExplorer::Abi> abiList;
foreach (const QString &abi, abis)
abiList << ProjectExplorer::Abi(abi);

View File

@@ -250,16 +250,8 @@ Target *BuildConfiguration::target() const
Utils::Environment BuildConfiguration::baseEnvironment() const
{
Utils::Environment result;
if (useSystemEnvironment()) {
#if 1
// workaround for QTBUG-35143
if (useSystemEnvironment())
result = Utils::Environment::systemEnvironment();
result.unset(QLatin1String("QSG_RENDER_LOOP"));
#else
result = Utils::Environment::systemEnvironment();
#endif
}
target()->kit()->addToEnvironment(result);
return result;
}

View File

@@ -357,12 +357,11 @@ QList<Task> DeviceKitInformation::validate(const Kit *k) const
void DeviceKitInformation::fix(Kit *k)
{
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
return;
if (!dev.isNull() && dev->type() != DeviceTypeKitInformation::deviceTypeId(k)) {
qWarning("Device is no longer known, removing from kit \"%s\".", qPrintable(k->displayName()));
setDeviceId(k, Core::Id());
}
}
void DeviceKitInformation::setup(Kit *k)
{

View File

@@ -69,23 +69,11 @@ Utils::Environment LocalEnvironmentAspect::baseEnvironment() const
if (BuildConfiguration *bc = runConfiguration()->target()->activeBuildConfiguration()) {
env = bc->environment();
} else { // Fallback for targets without buildconfigurations:
#if 1
// workaround for QTBUG-35143
env = Utils::Environment::systemEnvironment();
env.unset(QLatin1String("QSG_RENDER_LOOP"));
#else
env = Utils::Environment::systemEnvironment();
#endif
runConfiguration()->target()->kit()->addToEnvironment(env);
}
} else if (base == static_cast<int>(SystemEnvironmentBase)) {
#if 1
// workaround for QTBUG-35143
env = Utils::Environment::systemEnvironment();
env.unset(QLatin1String("QSG_RENDER_LOOP"));
#else
env = Utils::Environment::systemEnvironment();
#endif
}
if (const LocalApplicationRunConfiguration *rc = qobject_cast<const LocalApplicationRunConfiguration *>(runConfiguration()))

View File

@@ -51,14 +51,7 @@ QString QmlProjectEnvironmentAspect::baseEnvironmentDisplayName(int base) const
Utils::Environment QmlProjectManager::QmlProjectEnvironmentAspect::baseEnvironment() const
{
#if 1
// workaround for QTBUG-35143
Utils::Environment env = Utils::Environment::systemEnvironment();
env.unset(QLatin1String("QSG_RENDER_LOOP"));
return env;
#else
return Utils::Environment::systemEnvironment();
#endif
}
QmlProjectEnvironmentAspect::QmlProjectEnvironmentAspect(ProjectExplorer::RunConfiguration *rc) :

View File

@@ -175,6 +175,8 @@ private slots:
void test_checksymbols_VirtualMethodUse();
void test_checksymbols_LabelUse();
void test_checksymbols_MacroUse();
void test_checksymbols_Macros__FILE__LINE__DATE__TIME__1();
void test_checksymbols_Macros__FILE__LINE__DATE__TIME__2();
void test_checksymbols_FunctionUse();
void test_checksymbols_PseudoKeywordUse();
void test_checksymbols_StaticUse();
@@ -326,6 +328,55 @@ void tst_CheckSymbols::test_checksymbols_MacroUse()
TestData::check(source, expectedUses, macroUses);
}
void tst_CheckSymbols::test_checksymbols_Macros__FILE__LINE__DATE__TIME__1()
{
const QByteArray source =
"#define FILE_DATE_TIME __FILE__ \" / \" __DATE__ \" / \" __TIME__\n"
"#define LINE_NUMBER 0 + __LINE__\n"
"\n"
"void f()\n"
"{\n"
" class Printer;\n"
" Printer::printText(FILE_DATE_TIME); Printer::printInteger(LINE_NUMBER); Printer::nl();\n"
" return;\n"
"}\n";
const QList<Use> expectedUses = QList<Use>()
<< Use(4, 6, 1, CppHighlightingSupport::FunctionUse)
<< Use(6, 11, 7, CppHighlightingSupport::TypeUse)
<< Use(6, 11, 7, CppHighlightingSupport::TypeUse)
<< Use(7, 5, 7, CppHighlightingSupport::TypeUse)
<< Use(7, 41, 7, CppHighlightingSupport::TypeUse)
<< Use(7, 77, 7, CppHighlightingSupport::TypeUse)
;
TestData::check(source, expectedUses);
}
void tst_CheckSymbols::test_checksymbols_Macros__FILE__LINE__DATE__TIME__2()
{
const QByteArray source =
"void f()\n"
"{\n"
" class Printer;\n"
" Printer::printInteger(__LINE__); Printer::printText(__FILE__); Printer::nl();\n"
" Printer::printText(__DATE__); Printer::printText(__TIME__); Printer::nl();\n"
" return;\n"
"}\n";
const QList<Use> expectedUses = QList<Use>()
<< Use(1, 6, 1, CppHighlightingSupport::FunctionUse)
<< Use(3, 11, 7, CppHighlightingSupport::TypeUse)
<< Use(3, 11, 7, CppHighlightingSupport::TypeUse)
<< Use(4, 5, 7, CppHighlightingSupport::TypeUse)
<< Use(4, 38, 7, CppHighlightingSupport::TypeUse)
<< Use(4, 68, 7, CppHighlightingSupport::TypeUse)
<< Use(5, 5, 7, CppHighlightingSupport::TypeUse)
<< Use(5, 35, 7, CppHighlightingSupport::TypeUse)
<< Use(5, 65, 7, CppHighlightingSupport::TypeUse)
;
TestData::check(source, expectedUses);
}
void tst_CheckSymbols::test_checksymbols_FunctionUse()
{
const QByteArray source =

View File

@@ -334,6 +334,7 @@ private slots:
void unfinished_function_like_macro_call();
void nasty_macro_expansion();
void glib_attribute();
void builtin__FILE__();
void blockSkipping();
void includes_1();
void dont_eagerly_expand();
@@ -783,6 +784,27 @@ void tst_Preprocessor::glib_attribute()
QCOMPARE(preprocessed, result____);
}
void tst_Preprocessor::builtin__FILE__()
{
Client *client = 0; // no client.
Environment env;
Preprocessor preprocess(client, &env);
QByteArray preprocessed = preprocess.run(
QLatin1String("some-file.c"),
QByteArray("const char *f = __FILE__\n"
));
const QByteArray result____ =
"# 1 \"some-file.c\"\n"
"const char *f =\n"
"# expansion begin 16,8 ~1\n"
"\"some-file.c\"\n"
"# expansion end\n"
"# 2 \"some-file.c\"\n";
QCOMPARE(preprocessed, result____);
}
void tst_Preprocessor::comparisons_data()
{
QTest::addColumn<QString>("infile");

View File

@@ -154,7 +154,12 @@ def __createProjectHandleQtQuickSelection__(qtQuickVersion, withControls):
selectFromCombo(comboBox, "Qt Quick 2.0")
else:
test.fatal("Got unknown Qt Quick version: %s - trying to continue." % str(qtQuickVersion))
label = waitForObject("{type='QLabel' unnamed='1' visible='1' text?='Creates a *' }")
requires = re.match(".*Requires Qt (\d\.\d).*", str(label.text))
if requires:
requires = requires.group(1)
clickButton(waitForObject(":Next_QPushButton"))
return requires
# Selects the Qt versions for a project
# param checks turns tests in the function on if set to True
@@ -187,6 +192,30 @@ def __verifyFileCreation__(path, expectedFiles):
filename = os.path.join(path, filename)
test.verify(os.path.exists(filename), "Checking if '" + filename + "' was created")
def __modifyAvailableTargets__(available, requiredQt, asStrings=False):
threeDigits = re.compile("\d{3}")
requiredQtVersion = requiredQt.replace(".", "") + "0"
tmp = list(available) # we need a deep copy
for currentItem in tmp:
if asStrings:
item = currentItem
else:
item = Targets.getStringForTarget(currentItem)
found = threeDigits.search(item)
if found:
if found.group(0) < requiredQtVersion:
# Quick 1.1 supports 4.7.4 only for running, debugging is unsupported
# so the least required version is 4.8, but 4.7.4 will be still listed
if not (requiredQtVersion == "480" and found.group(0) == "474"):
available.remove(currentItem)
if requiredQtVersion > "480":
toBeRemoved = [Targets.EMBEDDED_LINUX, Targets.SIMULATOR]
if asStrings:
toBeRemoved = Targets.getTargetsAsStrings(toBeRemoved)
for t in toBeRemoved:
if t in available:
available.remove(t)
# Creates a Qt GUI project
# param path specifies where to create the project
# param projectName is the name for the new project
@@ -256,7 +285,8 @@ def createNewQtQuickApplication(workingDir, projectName = None,
fromWelcome=False, withControls=False):
available = __createProjectOrFileSelectType__(" Applications", "Qt Quick Application", fromWelcome)
projectName = __createProjectSetNameAndPath__(workingDir, projectName)
__createProjectHandleQtQuickSelection__(qtQuickVersion, withControls)
requiredQt = __createProjectHandleQtQuickSelection__(qtQuickVersion, withControls)
__modifyAvailableTargets__(available, requiredQt)
checkedTargets = __chooseTargets__(targets, available)
snooze(1)
clickButton(waitForObject(":Next_QPushButton"))

View File

@@ -33,7 +33,7 @@ import re
def main():
global tmpSettingsDir
global textChanged
quickCombinations = [[1,False], [2,False], [2,True]]
sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/text/textselection")
qmlFile = os.path.join("qml", "textselection.qml")
if not neededFilePresent(os.path.join(sourceExample, qmlFile)):
@@ -42,9 +42,6 @@ def main():
startApplication("qtcreator" + SettingsPath)
if not startedWithoutPluginError():
return
overrideInstallLazySignalHandler()
installLazySignalHandler(":frame.templateDescription_QTextBrowser",
"textChanged()","__handleTextChanged__")
kits = getConfiguredKits()
test.log("Collecting potential project types...")
availableProjectTypes = []
@@ -71,38 +68,35 @@ def main():
for template in dumpItems(templatesView.model(), templatesView.rootIndex()):
template = template.replace(".", "\\.")
# skip non-configurable
if not (template in ("Qt Quick 1 UI", "Qt Quick 2 UI", "Qt Quick 2 UI with Controls")
or "(CMake Build)" in template or "(Qbs Build)" in template):
if (template != "Qt Quick UI" and "(CMake Build)" not in template
and "(Qbs Build)" not in template):
availableProjectTypes.append({category:template})
clickButton(waitForObject("{text='Cancel' type='QPushButton' unnamed='1' visible='1'}"))
for current in availableProjectTypes:
category = current.keys()[0]
template = current.values()[0]
invokeMenuItem("File", "New File or Project...")
selectFromCombo(waitForObject(":New.comboBox_QComboBox"), "All Templates")
categoriesView = waitForObject(":New.templateCategoryView_QTreeView")
clickItem(categoriesView, "Projects." + category, 5, 5, 0, Qt.LeftButton)
templatesView = waitForObject("{name='templatesView' type='QListView' visible='1'}")
test.log("Verifying '%s' -> '%s'" % (category.replace("\\.", "."), template.replace("\\.", ".")))
textChanged = False
clickItem(templatesView, template, 5, 5, 0, Qt.LeftButton)
waitFor("textChanged", 2000)
text = waitForObject(":frame.templateDescription_QTextBrowser").plainText
displayedPlatforms = __getSupportedPlatforms__(str(text), template, True)[0]
clickButton(waitForObject("{text='Choose...' type='QPushButton' unnamed='1' visible='1'}"))
# don't check because project could exist
__createProjectSetNameAndPath__(os.path.expanduser("~"), 'untitled', False)
displayedPlatforms = __createProject__(category, template)
if template == "Qt Quick Application":
for counter, qComb in enumerate(quickCombinations):
requiredQtVersion = __createProjectHandleQtQuickSelection__(qComb[0], qComb[1])
__modifyAvailableTargets__(displayedPlatforms, requiredQtVersion, True)
verifyKitCheckboxes(kits, displayedPlatforms)
# FIXME: if QTBUG-35203 is fixed replace by triggering the shortcut for Back
clickButton(waitForObject("{type='QPushButton' text='Cancel'}"))
# are there more Quick combinations - then recreate this project
if counter < len(quickCombinations) - 1:
displayedPlatforms = __createProject__(category, template)
continue
try:
waitForObject("{name='mainQmlFileGroupBox' title='Main HTML File' type='QGroupBox' visible='1'}", 1000)
clickButton(waitForObject(":Next_QPushButton"))
except LookupError:
try:
waitForObject("{text='Select Existing QML file' type='QLabel' visible='1'}", 1000)
baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}")
type(baseLineEd, os.path.join(templateDir, qmlFile))
clickButton(waitForObject(":Next_QPushButton"))
except LookupError:
pass
verifyKitCheckboxes(kits, displayedPlatforms)
clickButton(waitForObject("{type='QPushButton' text='Cancel'}"))
invokeMenuItem("File", "Exit")
def verifyKitCheckboxes(kits, displayedPlatforms):
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
availableCheckboxes = filter(visibleCheckBoxExists, kits.keys())
# verification whether expected, found and configured match
@@ -121,9 +115,20 @@ def main():
if len(availableCheckboxes) != 0:
test.fail("Found unexpected additional kit(s) %s on 'Kit Selection' page."
% str(availableCheckboxes))
clickButton(waitForObject("{text='Cancel' type='QPushButton' unnamed='1' visible='1'}"))
invokeMenuItem("File", "Exit")
def __handleTextChanged__(*args):
global textChanged
textChanged = True
def __createProject__(category, template):
invokeMenuItem("File", "New File or Project...")
selectFromCombo(waitForObject(":New.comboBox_QComboBox"), "All Templates")
categoriesView = waitForObject(":New.templateCategoryView_QTreeView")
clickItem(categoriesView, "Projects." + category, 5, 5, 0, Qt.LeftButton)
templatesView = waitForObject("{name='templatesView' type='QListView' visible='1'}")
test.log("Verifying '%s' -> '%s'" % (category.replace("\\.", "."), template.replace("\\.", ".")))
textBrowser = findObject(":frame.templateDescription_QTextBrowser")
origTxt = str(textBrowser.plainText)
clickItem(templatesView, template, 5, 5, 0, Qt.LeftButton)
waitFor("origTxt != str(textBrowser.plainText)", 2000)
displayedPlatforms = __getSupportedPlatforms__(str(textBrowser.plainText), template, True)[0]
clickButton(waitForObject("{text='Choose...' type='QPushButton' unnamed='1' visible='1'}"))
# don't check because project could exist
__createProjectSetNameAndPath__(os.path.expanduser("~"), 'untitled', False)
return displayedPlatforms