From e3021b7178fd557de5e10c55db5875e0eff73b2e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 19 Oct 2018 14:00:28 +0200 Subject: [PATCH 1/3] Fix crash in folder navigation widget We want to delay updating the crumble path, but we may not keep and pass around the QModelIndex, since that can become invalid. Change-Id: Id0c1ffb046dda1fb3bc09801fd1952787f9919fa Reviewed-by: Eike Ziller --- .../foldernavigationwidget.cpp | 28 +++++++++++++------ .../projectexplorer/foldernavigationwidget.h | 4 ++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index b0df6203754..f6853ef9a2e 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -373,13 +373,25 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent) : QWidget(parent connect(m_listView, &QAbstractItemView::activated, this, [this](const QModelIndex &index) { openItem(m_sortProxyModel->mapToSource(index)); }); - // use QueuedConnection for updating crumble path, because that can scroll, which doesn't - // work well when done directly in currentChanged (the wrong item can get highlighted) + // Delay updating crumble path by event loop cylce, because that can scroll, which doesn't + // work well when done directly in currentChanged (the wrong item can get highlighted). + // We cannot use Qt::QueuedConnection directly, because the QModelIndex could get invalidated + // in the meantime, so use a queued invokeMethod instead. connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, - &FolderNavigationWidget::setCrumblePath, - Qt::QueuedConnection); + [this](const QModelIndex &index) { + const QModelIndex sourceIndex = m_sortProxyModel->mapToSource(index); + const auto filePath = Utils::FileName::fromString( + m_fileSystemModel->filePath(sourceIndex)); + // QTimer::singleShot only posts directly onto the event loop if you use the SLOT("...") + // notation, so using a singleShot with a lambda would flicker + // QTimer::singleShot(0, this, [this, filePath]() { setCrumblePath(filePath); }); + QMetaObject::invokeMethod(this, + "setCrumblePath", + Qt::QueuedConnection, + Q_ARG(Utils::FileName, filePath)); + }); connect(m_crumbLabel, &Utils::FileCrumbLabel::pathClicked, [this](const Utils::FileName &path) { const QModelIndex rootIndex = m_sortProxyModel->mapToSource(m_listView->rootIndex()); const QModelIndex fileIndex = m_fileSystemModel->index(path.toString()); @@ -623,7 +635,7 @@ void FolderNavigationWidget::selectFile(const Utils::FileName &filePath) } else { m_listView->scrollTo(fileIndex); } - setCrumblePath(fileIndex); + setCrumblePath(filePath); }); } } @@ -699,12 +711,12 @@ void FolderNavigationWidget::createNewFolder(const QModelIndex &parent) m_listView->edit(index); } -void FolderNavigationWidget::setCrumblePath(const QModelIndex &index) +void FolderNavigationWidget::setCrumblePath(const Utils::FileName &filePath) { - const QModelIndex sourceIndex = m_sortProxyModel->mapToSource(index); + const QModelIndex index = m_fileSystemModel->index(filePath.toString()); const int width = m_crumbLabel->width(); const int previousHeight = m_crumbLabel->immediateHeightForWidth(width); - m_crumbLabel->setPath(Utils::FileName::fromString(m_fileSystemModel->filePath(sourceIndex))); + m_crumbLabel->setPath(filePath); const int currentHeight = m_crumbLabel->immediateHeightForWidth(width); const int diff = currentHeight - previousHeight; if (diff != 0 && m_crumbLabel->isVisible()) { diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h index f10f69d595d..5c8a2e24f6a 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.h +++ b/src/plugins/projectexplorer/foldernavigationwidget.h @@ -118,6 +118,9 @@ public: protected: void contextMenuEvent(QContextMenuEvent *ev) override; +private slots: + void setCrumblePath(const Utils::FileName &filePath); + private: bool rootAutoSynchronization() const; void setRootAutoSynchronization(bool sync); @@ -131,7 +134,6 @@ private: QStringList projectsInDirectory(const QModelIndex &index) const; void openProjectsInDirectory(const QModelIndex &index); void createNewFolder(const QModelIndex &parent); - void setCrumblePath(const QModelIndex &index); Core::IContext *m_context = nullptr; Utils::NavigationTreeView *m_listView = nullptr; From b605ad61bc17f1d7f3daf900e477ffb7bbaa1417 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 22 Oct 2018 11:28:36 +0200 Subject: [PATCH 2/3] iOS: Work around mismatch of USB serial and iOS device id Currently we track connection of devices in the iOS plugin via USB, using the USB serial number as a device identifier (iosdevice.h/cpp). On the other side, iostool uses the MobileDevice framework to identify iOS devices (iosdevicemanager.h/cpp). The assumption that the two identifiers are the same seems to be no longer true with the iPhone XS devices. These have a device identifier that contains a dash that is not present in the USB serial number. As a hotfix, just remove any dashes from the identifier on the iostool side because we only use it for the lookup deviceId -> AMDeviceRef anyhow. The longer term fix should be to use MobileDevice framework for the connection tracking of devices on the iOS plugin side as well, instead on relying on questionable assumptions. Change-Id: Iac3115a1c3f43a4f9e159aaa4ded1c671c55d888 Fixes: QTCREATORBUG-21291 Reviewed-by: Jason Hihn Reviewed-by: Vikas Pachdha --- src/tools/iostool/iosdevicemanager.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/tools/iostool/iosdevicemanager.cpp b/src/tools/iostool/iosdevicemanager.cpp index bfc493ad5af..53a9fd1625a 100644 --- a/src/tools/iostool/iosdevicemanager.cpp +++ b/src/tools/iostool/iosdevicemanager.cpp @@ -423,6 +423,7 @@ public: void requestDeviceInfo(const QString &deviceId, int timeout); QStringList errors(); void addError(QString errorMsg); + QString deviceId(AMDeviceRef device); void addDevice(AMDeviceRef device); void removeDevice(AMDeviceRef device); void checkPendingLookups(); @@ -654,11 +655,18 @@ void IosDeviceManagerPrivate::addError(QString errorMsg) emit q->errorMsg(errorMsg); } -void IosDeviceManagerPrivate::addDevice(AMDeviceRef device) +QString IosDeviceManagerPrivate::deviceId(AMDeviceRef device) { CFStringRef s = m_lib.deviceCopyDeviceIdentifier(device); - QString devId = QString::fromCFString(s); + // remove dashes as a hotfix for QTCREATORBUG-21291 + const auto id = QString::fromCFString(s).remove('-'); if (s) CFRelease(s); + return id; +} + +void IosDeviceManagerPrivate::addDevice(AMDeviceRef device) +{ + const QString devId = deviceId(device); CFRetain(device); DeviceInterfaceType interfaceType = static_cast(lib()->deviceGetInterfaceType(device)); @@ -703,10 +711,7 @@ void IosDeviceManagerPrivate::addDevice(AMDeviceRef device) void IosDeviceManagerPrivate::removeDevice(AMDeviceRef device) { - CFStringRef s = m_lib.deviceCopyDeviceIdentifier(device); - QString devId = QString::fromCFString(s); - if (s) - CFRelease(s); + const QString devId = deviceId(device); if (debugAll) qDebug() << "removeDevice " << devId; if (m_devices.contains(devId)) { From 66ed57ce3eb50983c58eb1877bc6cc37df58eb9a Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 23 Oct 2018 09:53:18 +0200 Subject: [PATCH 3/3] More change log for 4.7.2 Change-Id: I96f8678b0f0658aa72689fcefa410c5e26af50e9 Reviewed-by: Leena Miettinen --- dist/changes-4.7.2.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/changes-4.7.2.md b/dist/changes-4.7.2.md index 262463113f3..710e6e4f13b 100644 --- a/dist/changes-4.7.2.md +++ b/dist/changes-4.7.2.md @@ -7,11 +7,21 @@ you can check out from the public Git repository. For example: git clone git://code.qt.io/qt-creator/qt-creator.git git log --cherry-pick --pretty=oneline origin/v4.7.1..v4.7.2 +General + +* Fixed crash when pressing wrong shortcut for recent projects in Welcome mode + (QTCREATORBUG-21302) +* Fixed rare crash in file system view + Editing * Fixed that collapsed text no longer showed up in tooltip (QTCREATORBUG-21040) * Fixed crash with generic text completion (QTCREATORBUG-21192) +Generic Projects + +* Fixed crash when adding file to sub-folder (QTCREATORBUG-21342) + C++ Support * Fixed wrong value of `__cplusplus` define (QTCREATORBUG-20884) @@ -31,6 +41,11 @@ Windows * Fixed saving of files when another application blocks atomic save operation (QTCREATORBUG-7668) +* Fixed wrongly added empty lines in application output (QTCREATORBUG-21215) + +iOS + +* Fixed issue with detecting iPhone XS (QTCREATORBUG-21291) Remote Linux