summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-01-26 08:47:06 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-01-29 09:32:08 +0000
commit9cc6a9b3af559004bbfdfec3aa7dd258bee1eb77 (patch)
treef632da853067c7dc01b134fb7ba8b0e4550e1d3d /examples
parent4706708254176ca2b971a709697d0e8c77f55974 (diff)
Fix crashing btchat example when selecting remote devicev5.4.1
The example immidiately destroys the QBluetoothServiceDiscoveryAgent when the user selects a remote chat service from the remote selector dialog. This may happen even when the scheduled QtConcurrent call to runSdpScan() was still pending. The subsequent signal callback into the deleted parent caused a crash. Unfortunately QtConcurrent::run() returns a QFuture which does not permit stopping the pending thread execution. Therefore the runSdpScan() had to be rewritten using QProcess to properly destruct pending calls. Change-Id: I1ed5e147feb94a26240901a02d836056eddabbf6 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/bluetooth/btchat/main.cpp2
-rw-r--r--examples/bluetooth/btchat/remoteselector.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/examples/bluetooth/btchat/main.cpp b/examples/bluetooth/btchat/main.cpp
index ac23a11d..ed362d23 100644
--- a/examples/bluetooth/btchat/main.cpp
+++ b/examples/bluetooth/btchat/main.cpp
@@ -41,9 +41,11 @@
#include "chat.h"
#include <QApplication>
+//#include <QtCore/QLoggingCategory>
int main(int argc, char *argv[])
{
+ //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
QApplication app(argc, argv);
Chat d;
diff --git a/examples/bluetooth/btchat/remoteselector.cpp b/examples/bluetooth/btchat/remoteselector.cpp
index 79dc0564..913988a2 100644
--- a/examples/bluetooth/btchat/remoteselector.cpp
+++ b/examples/bluetooth/btchat/remoteselector.cpp
@@ -136,6 +136,8 @@ void RemoteSelector::on_remoteDevices_itemActivated(QListWidgetItem *item)
{
qDebug() << "got click" << item->text();
m_service = m_discoveredServices.value(item);
+ if (m_discoveryAgent->isActive())
+ m_discoveryAgent->stop();
accept();
}