Qnx: Fix device connection issue

BlackBerry device connections need the Qnx environments
to be set first to find the path to the conenct.jar package.
The device connection at startup needs to wait
for the Qnx setting to be loaded.

Change-Id: I89ad41a65da951f9f9c7a702346f8d4bb428d1cd
Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com>
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
El Mehdi Fekari
2013-08-27 15:17:10 +02:00
committed by Mehdi Fekari
parent 7f6265f62f
commit 0e669ace19
4 changed files with 34 additions and 0 deletions

View File

@@ -328,6 +328,8 @@ void BlackBerryConfigurationManager::loadSettings()
loadAutoDetectedConfigurations();
loadManualConfigurations();
loadCertificates();
emit settingsLoaded();
}
void BlackBerryConfigurationManager::clearConfigurationSettings(BlackBerryConfiguration *config)

View File

@@ -75,6 +75,9 @@ public slots:
void loadSettings();
void saveSettings();
signals:
void settingsLoaded();
private:
BlackBerryConfigurationManager(QObject *parent = 0);
static BlackBerryConfigurationManager *m_instance;

View File

@@ -33,6 +33,7 @@
#include "blackberrydeviceconfiguration.h"
#include "blackberrydeviceconnection.h"
#include "blackberryconfigurationmanager.h"
#include "qnxconstants.h"
#include <coreplugin/icore.h>
@@ -110,6 +111,16 @@ void BlackBerryDeviceConnectionManager::connectDevice(Core::Id deviceId)
if (device.isNull())
return;
// BlackBerry Device connection needs the Qnx environments to be set
// in order to find the Connect.jar package.
// Let's delay the device connections at startup till the Qnx settings are loaded.
if (BlackBerryConfigurationManager::instance().configurations().isEmpty()) {
m_pendingDeviceConnections << device;
connect(&BlackBerryConfigurationManager::instance(), SIGNAL(settingsLoaded()),
this, SLOT(processPendingDeviceConnections()), Qt::UniqueConnection);
return;
}
connectDevice(device);
}
@@ -292,6 +303,20 @@ void BlackBerryDeviceConnectionManager::handleProcessOutput(const QString &outpu
emit connectionOutput(deviceId, output);
}
void BlackBerryDeviceConnectionManager::processPendingDeviceConnections()
{
if (m_pendingDeviceConnections.isEmpty()
|| BlackBerryConfigurationManager::instance().configurations().isEmpty())
return;
foreach (ProjectExplorer::IDevice::ConstPtr device, m_pendingDeviceConnections)
connectDevice(device);
m_pendingDeviceConnections.clear();
disconnect(&BlackBerryConfigurationManager::instance(), SIGNAL(settingsLoaded()),
this, SLOT(processPendingDeviceConnections()));
}
BlackBerryDeviceConnection *BlackBerryDeviceConnectionManager::connectionForHost(const QString &host) const
{
QList<BlackBerryDeviceConnection*> connections = m_connections.uniqueKeys();

View File

@@ -83,6 +83,8 @@ private slots:
void handleProcessOutput(const QString &output);
void processPendingDeviceConnections();
private:
explicit BlackBerryDeviceConnectionManager();
@@ -97,6 +99,8 @@ private:
static BlackBerryDeviceConnectionManager *m_instance;
QMultiMap<BlackBerryDeviceConnection*, Core::Id> m_connections;
QList<ProjectExplorer::IDevice::ConstPtr> m_pendingDeviceConnections;
};
} // namespace Internal