From e22eea1cf3c9f884d872d4f4c32cd5f320a27786 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 17 Feb 2020 20:13:35 +0100 Subject: [PATCH 1/7] Fix the Python templates This fixes the templates so that they do not produce any warnings and also includes QQuickItem in the choice of base classes Change-Id: I58bbd462052f5d2a64bb8c4bea5bbdcd15e66700 Reviewed-by: Cristian Maureira-Fredes --- share/qtcreator/templates/wizards/classes/python/file.py | 7 +++---- .../qtcreator/templates/wizards/classes/python/wizard.json | 2 +- share/qtcreator/templates/wizards/files/python/file.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/templates/wizards/classes/python/file.py b/share/qtcreator/templates/wizards/classes/python/file.py index adcbc1ed2d0..5698022dd85 100644 --- a/share/qtcreator/templates/wizards/classes/python/file.py +++ b/share/qtcreator/templates/wizards/classes/python/file.py @@ -21,6 +21,7 @@ from PyQt5 import QtQuick @endif @endif + @if '%{Base}' class %{Class}(%{Base}): @else @@ -29,11 +30,9 @@ class %{Class}: def __init__(self): @if '%{Base}' === 'QWidget' QtWidgets.QWidget.__init__(self) -@endif -@if '%{Base}' === 'QMainWindow' +@elif '%{Base}' === 'QMainWindow' QtWidgets.QMainWindow.__init__(self) -@if '%{Base}' === 'QQuickItem' +@elif '%{Base}' === 'QQuickItem' QtQuick.QQuickItem.__init__(self) @endif pass - diff --git a/share/qtcreator/templates/wizards/classes/python/wizard.json b/share/qtcreator/templates/wizards/classes/python/wizard.json index 552c3f15a0e..aeebd1f2a30 100644 --- a/share/qtcreator/templates/wizards/classes/python/wizard.json +++ b/share/qtcreator/templates/wizards/classes/python/wizard.json @@ -46,7 +46,7 @@ "data": { "items": [ { "trKey": "", "value": "" }, - "QObject", "QWidget", "QMainWindow", "QDeclarativeItem" ] + "QObject", "QWidget", "QMainWindow", "QDeclarativeItem", "QQuickItem" ] } }, { diff --git a/share/qtcreator/templates/wizards/files/python/file.py b/share/qtcreator/templates/wizards/files/python/file.py index 003f8414973..fcb605f9f72 100644 --- a/share/qtcreator/templates/wizards/files/python/file.py +++ b/share/qtcreator/templates/wizards/files/python/file.py @@ -1,4 +1,4 @@ # This Python file uses the following encoding: utf-8 -# if__name__ == "__main__": +# if __name__ == "__main__": # pass From c34864ccab116571409b772cd9a109b87331348d Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 18 Feb 2020 15:36:11 +0100 Subject: [PATCH 2/7] macOS: Disable library validation when signing So we can load 3rdparty plugins even when the app is signed and notarized. Also give Qt Creator "debugging" capabilities, allowing it to attach to processes. Change-Id: Ia6bb8ab279920b75a96777eafebbb4e7454fda46 Reviewed-by: Eike Ziller --- dist/installer/mac/entitlements.plist | 10 ++++++++++ scripts/common.py | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 dist/installer/mac/entitlements.plist diff --git a/dist/installer/mac/entitlements.plist b/dist/installer/mac/entitlements.plist new file mode 100644 index 00000000000..0aae7ab39d9 --- /dev/null +++ b/dist/installer/mac/entitlements.plist @@ -0,0 +1,10 @@ + + + + + com.apple.security.cs.debugger + + com.apple.security.cs.disable-library-validation + + + diff --git a/scripts/common.py b/scripts/common.py index db97ea35616..e1746f4700e 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -211,5 +211,7 @@ def codesign(app_path): lambda ff: ff.endswith('.dylib')) codesign = codesign_call() if is_mac_platform() and codesign: + entitlements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'dist', + 'installer', 'mac', 'entitlements.plist') # sign the whole bundle - subprocess.check_call(codesign + ['--deep', app_path]) + subprocess.check_call(codesign + ['--deep', app_path, '--entitlements', entitlements_path]) From aee78bd58db609efc729cf883e91049e0e342049 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 20 Feb 2020 08:26:32 +0100 Subject: [PATCH 3/7] Editor: do not split on nbsp in rewrap paragraph Change-Id: I443400056f647a58a98d9bb6a221b10852470ba2 Fixes: QTCREATORBUG-23643 Reviewed-by: Eike Ziller --- src/plugins/texteditor/texteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index ac84aca67c9..58ade7f6e7b 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -7165,7 +7165,7 @@ void TextEditorWidget::rewrapParagraph() QString currentWord; for (const QChar &ch : qAsConst(selectedText)) { - if (ch.isSpace()) { + if (ch.isSpace() && ch != QChar::Nbsp) { if (!currentWord.isEmpty()) { currentLength += currentWord.length() + 1; From 63e9c4c31ae3c6529f199c23d9e82fe961bf64c9 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 25 Feb 2020 10:00:12 +0100 Subject: [PATCH 4/7] Editor: Prevent setting negative position in block selection Fixes: QTCREATORBUG-23622 Change-Id: I0f041a772869695e7d460effd4b0d58f94ce55ec Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 58ade7f6e7b..a48d58d1261 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -5466,7 +5466,7 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e) column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' ')); d->m_blockSelection.positionBlock = cursor.blockNumber(); - d->m_blockSelection.positionColumn = column; + d->m_blockSelection.positionColumn = qMax(0, column); doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); viewport()->update(); @@ -8035,12 +8035,12 @@ QTextCursor TextBlockSelection::cursor(const TextDocument *baseTextDocument, } void TextBlockSelection::fromPostition(int positionBlock, int positionColumn, - int anchorBlock, int anchorColumn) + int anchorBlock, int anchorColumn) { - this->positionBlock = positionBlock; - this->positionColumn = positionColumn; - this->anchorBlock = anchorBlock; - this->anchorColumn = anchorColumn; + this->positionBlock = QTC_GUARD(positionBlock >= 0) ? positionBlock : 0; + this->positionColumn = QTC_GUARD(positionColumn >= 0) ? positionColumn : 0; + this->anchorBlock = QTC_GUARD(anchorBlock >= 0) ? anchorBlock : 0; + this->anchorColumn = QTC_GUARD(anchorColumn >= 0) ? anchorColumn : 0; } bool TextEditorWidget::inFindScope(const QTextCursor &cursor) From 83eab470c10f885d54974b30fa8fb0ec4a1f8f23 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 25 Feb 2020 13:27:03 +0100 Subject: [PATCH 5/7] LanguageClient: Only send position changed signals to reachable clients Change-Id: I0d387ea10aeba8f5f1be3d0ddb6a6ccb82e04e64 Reviewed-by: Christian Stenger --- src/plugins/languageclient/languageclientmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/languageclient/languageclientmanager.cpp b/src/plugins/languageclient/languageclientmanager.cpp index 543ec74a20a..9ca9d06f358 100644 --- a/src/plugins/languageclient/languageclientmanager.cpp +++ b/src/plugins/languageclient/languageclientmanager.cpp @@ -397,7 +397,8 @@ void LanguageClientManager::editorOpened(Core::IEditor *editor) if (!widget) return; if (Client *client = clientForDocument(widget->textDocument())) - client->cursorPositionChanged(widget); + if (client->reachable()) + client->cursorPositionChanged(widget); }); }); updateEditorToolBar(editor); From 45381e9d04c7494978dd5cc6a5854a704ef039ba Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 25 Feb 2020 13:27:46 +0100 Subject: [PATCH 6/7] LanguageClient: Only send contentsChanged notification to reachable clients Change-Id: Id35b94d3c6f9b3b08b1e66b992ca5fe86cdab6d5 Reviewed-by: Christian Stenger --- src/plugins/languageclient/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 7a8d305550c..a704889fe66 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -466,7 +466,7 @@ void Client::documentContentsChanged(TextEditor::TextDocument *document, int charsRemoved, int charsAdded) { - if (!m_openedDocument.contains(document)) + if (!m_openedDocument.contains(document) || !reachable()) return; const QString method(DidChangeTextDocumentNotification::methodName); TextDocumentSyncKind syncKind = m_serverCapabilities.textDocumentSyncKindHelper(); From 8625bbfe5a7cd9de4139a5d80f3479386c8594bd Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 25 Feb 2020 13:30:20 +0100 Subject: [PATCH 7/7] LanguageClient: Fix client restart after crash Do not clear open documents but disconnect and deactivate them, so they can be correctly reopened once the server is restarted. Change-Id: I0f61a5461c020865e61d9808e8c645ea842f64ad Fixes: QTCREATORBUG-23648 Reviewed-by: Christian Stenger --- src/plugins/languageclient/client.cpp | 3 ++- src/plugins/languageclient/languageclientmanager.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index a704889fe66..74e0e91db3c 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -808,11 +808,12 @@ bool Client::reset() m_responseHandlers.clear(); m_clientInterface->resetBuffer(); updateEditorToolBar(m_openedDocument.keys()); - m_openedDocument.clear(); m_serverCapabilities = ServerCapabilities(); m_dynamicCapabilities.reset(); for (const DocumentUri &uri : m_diagnostics.keys()) removeDiagnostics(uri); + for (TextEditor::TextDocument *document : m_openedDocument.keys()) + document->disconnect(this); for (TextEditor::TextDocument *document : m_resetAssistProvider.keys()) resetAssistProviders(document); return true; diff --git a/src/plugins/languageclient/languageclientmanager.cpp b/src/plugins/languageclient/languageclientmanager.cpp index 9ca9d06f358..384b78c72df 100644 --- a/src/plugins/languageclient/languageclientmanager.cpp +++ b/src/plugins/languageclient/languageclientmanager.cpp @@ -366,6 +366,8 @@ void LanguageClientManager::clientFinished(Client *client) client->log(tr("Unexpectedly finished. Restarting in %1 seconds.").arg(restartTimeoutS), Core::MessageManager::Flash); QTimer::singleShot(restartTimeoutS * 1000, client, [client]() { startClient(client); }); + for (TextEditor::TextDocument *document : m_clientForDocument.keys(client)) + client->deactivateDocument(document); } else { if (unexpectedFinish && !m_shuttingDown) client->log(tr("Unexpectedly finished."), Core::MessageManager::Flash);