forked from qt-creator/qt-creator
Fix for crash when stopping running an app over CODA TCP
This commit is contained in:
committed by
Pawel Polanski
parent
b9614cdf7d
commit
2cc342a882
@@ -134,7 +134,7 @@ bool CodaRunControl::setupLauncher()
|
||||
m_codaDevice->sendSerialPing(false);
|
||||
} else {
|
||||
// For TCP we don't use device manager, we just set it up directly
|
||||
m_codaDevice = QSharedPointer<Coda::CodaDevice>(new Coda::CodaDevice);
|
||||
m_codaDevice = QSharedPointer<Coda::CodaDevice>(new Coda::CodaDevice, &QObject::deleteLater); // finishRunControl, which deletes m_codaDevice, can get called from within a coda callback, so need to use deleteLater
|
||||
connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotTrkLogMessage(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(tcfEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)));
|
||||
|
||||
@@ -550,10 +550,11 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
|
||||
setDeviceInfoLabel(tr("Currently there is no information about the device for this connection type."), true);
|
||||
}
|
||||
|
||||
void S60DeployConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
void S60DeployConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
if (result.type == Coda::CodaCommandResult::FailReply) {
|
||||
setDeviceInfoLabel(tr("No device information available"), true);
|
||||
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
|
||||
m_deviceInfoButton->setEnabled(true);
|
||||
return;
|
||||
} else if (result.type == Coda::CodaCommandResult::CommandErrorReply){
|
||||
@@ -627,10 +628,10 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
|
||||
setDeviceInfoLabel(resultString);
|
||||
}
|
||||
m_codaInfoDevice->sendSymbianOsDataGetRomInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getRomInfoResult));
|
||||
}
|
||||
}
|
||||
|
||||
void S60DeployConfigurationWidget::getRomInfoResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
void S60DeployConfigurationWidget::getRomInfoResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
|
||||
QString resultString = m_deviceInfoLabel->text();
|
||||
startTable(resultString);
|
||||
@@ -652,10 +653,10 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
|
||||
packagesOfInterest.append(CODA_UID);
|
||||
packagesOfInterest.append(QTMOBILITY_UID);
|
||||
m_codaInfoDevice->sendSymbianInstallGetPackageInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getInstalledPackagesResult), packagesOfInterest);
|
||||
}
|
||||
}
|
||||
|
||||
void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
|
||||
QString resultString = m_deviceInfoLabel->text();
|
||||
startTable(resultString);
|
||||
@@ -704,10 +705,10 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
|
||||
keys << QLatin1String("EDisplayYPixels");
|
||||
//keys << "EMemoryRAMFree";
|
||||
m_codaInfoDevice->sendSymbianOsDataGetHalInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getHalResult), keys);
|
||||
}
|
||||
}
|
||||
|
||||
void S60DeployConfigurationWidget::getHalResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
void S60DeployConfigurationWidget::getHalResult(const Coda::CodaCommandResult &result)
|
||||
{
|
||||
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
|
||||
QString resultString = m_deviceInfoLabel->text();
|
||||
QVariantList resultsList = result.values[0].toVariant().toList();
|
||||
@@ -732,7 +733,7 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
|
||||
// Done with collecting info
|
||||
m_deviceInfoButton->setEnabled(true);
|
||||
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -274,7 +274,7 @@ struct SymbianDeviceManagerPrivate {
|
||||
//QSignalMapper *m_destroyReleaseMapper;
|
||||
// The following 2 variables are needed to manage requests for a TCF port not coming from the main thread
|
||||
int m_constructTcfPortEventType;
|
||||
QMutex m_tcfPortWaitMutex;
|
||||
QMutex m_codaPortWaitMutex;
|
||||
};
|
||||
|
||||
class QConstructTcfPortEvent : public QEvent
|
||||
@@ -375,16 +375,16 @@ CodaDevicePtr SymbianDeviceManager::getCodaDevice(const QString &port)
|
||||
// Check we instanciate in the correct thread - we can't afford to create the CodaDevice (and more specifically, open the VirtualSerialDevice) in a thread that isn't guaranteed to be long-lived.
|
||||
// Therefore, if we're not in SymbianDeviceManager's thread, rejig things so it's opened in the main thread
|
||||
if (QThread::currentThread() != thread()) {
|
||||
// SymbianDeviceManager is owned by the current thread
|
||||
d->m_tcfPortWaitMutex.lock();
|
||||
// SymbianDeviceManager is owned by the main thread
|
||||
d->m_codaPortWaitMutex.lock();
|
||||
QWaitCondition waiter;
|
||||
QCoreApplication::postEvent(this, new QConstructTcfPortEvent((QEvent::Type)d->m_constructTcfPortEventType, port, &devicePtr, &waiter));
|
||||
waiter.wait(&d->m_tcfPortWaitMutex);
|
||||
waiter.wait(&d->m_codaPortWaitMutex);
|
||||
// When the wait returns (due to the wakeAll in SymbianDeviceManager::customEvent), the CodaDevice will be fully set up
|
||||
d->m_tcfPortWaitMutex.unlock();
|
||||
d->m_codaPortWaitMutex.unlock();
|
||||
} else {
|
||||
// We're in the main thread, just set it up directly
|
||||
constructTcfPort(devicePtr, port);
|
||||
constructCodaPort(devicePtr, port);
|
||||
}
|
||||
// We still carry on in the case we failed to open so the client can access the IODevice's errorString()
|
||||
}
|
||||
@@ -393,9 +393,9 @@ CodaDevicePtr SymbianDeviceManager::getCodaDevice(const QString &port)
|
||||
return devicePtr;
|
||||
}
|
||||
|
||||
void SymbianDeviceManager::constructTcfPort(CodaDevicePtr& device, const QString& portName)
|
||||
void SymbianDeviceManager::constructCodaPort(CodaDevicePtr& device, const QString& portName)
|
||||
{
|
||||
QMutexLocker locker(&d->m_tcfPortWaitMutex);
|
||||
QMutexLocker locker(&d->m_codaPortWaitMutex);
|
||||
if (device.isNull()) {
|
||||
device = QSharedPointer<Coda::CodaDevice>(new Coda::CodaDevice);
|
||||
const QSharedPointer<SymbianUtils::VirtualSerialDevice> serialDevice(new SymbianUtils::VirtualSerialDevice(portName));
|
||||
@@ -414,7 +414,7 @@ void SymbianDeviceManager::customEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == d->m_constructTcfPortEventType) {
|
||||
QConstructTcfPortEvent* constructEvent = static_cast<QConstructTcfPortEvent*>(event);
|
||||
constructTcfPort(*constructEvent->m_device, constructEvent->m_portName);
|
||||
constructCodaPort(*constructEvent->m_device, constructEvent->m_portName);
|
||||
constructEvent->m_waiter->wakeAll(); // Should only ever be one thing waiting on this
|
||||
}
|
||||
}
|
||||
@@ -680,7 +680,7 @@ qint64 OstChannel::readData(char *data, qint64 maxSize)
|
||||
|
||||
qint64 OstChannel::writeData(const char *data, qint64 maxSize)
|
||||
{
|
||||
static const qint64 KMaxOstPayload = 1022;
|
||||
static const qint64 KMaxOstPayload = 1024;
|
||||
// If necessary, split the packet up
|
||||
while (maxSize) {
|
||||
QByteArray dataBuf = QByteArray::fromRawData(data, qMin(KMaxOstPayload, maxSize));
|
||||
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
SymbianDeviceList serialPorts() const;
|
||||
SymbianDeviceList blueToothDevices() const;
|
||||
void customEvent(QEvent *event);
|
||||
void constructTcfPort(CodaDevicePtr& device, const QString& portName);
|
||||
void constructCodaPort(CodaDevicePtr& device, const QString& portName);
|
||||
|
||||
SymbianDeviceManagerPrivate *d;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user