From 7793426059483d152f578740192989c15f510721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Thu, 21 Jan 2010 05:44:42 +0000 Subject: [PATCH] Fix segv when switching from a call that was previously hungup. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16432 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- fscomm/call.h | 1 + fscomm/fshost.cpp | 18 ++++++++++++++++++ fscomm/mainwindow.cpp | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/fscomm/call.h b/fscomm/call.h index 6ec45d2076..b02459e4b9 100644 --- a/fscomm/call.h +++ b/fscomm/call.h @@ -49,6 +49,7 @@ class Call { public: Call(); Call(int call_id, QString cid_name, QString cid_number, fscomm_call_direction_t direction, QString uuid); + /*~Call() { qDebug() << "I am being freed uuid: " << _uuid; }*/ QString getCidName(void) { return _cid_name; } QString getCidNumber(void) { return _cid_number; } int getCallID(void) { return _call_id; } diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index 2eb926f471..9533806e87 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -162,6 +162,15 @@ switch_status_t FSHost::processAlegEvent(switch_event_t * event, QString uuid) { switch_status_t status = SWITCH_STATUS_SUCCESS; QSharedPointer call = _active_calls.value(uuid); + + if (call.isNull()) + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "We don't have a call object for A leg on event %s.\n", switch_event_name(event->event_id)); + qDebug() << _active_calls.keys(); + printEventHeaders(event); + return SWITCH_STATUS_FALSE; + } + /* Inbound call */ if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND) { @@ -226,6 +235,15 @@ switch_status_t FSHost::processBlegEvent(switch_event_t * event, QString buuid) QString uuid = _bleg_uuids.value(buuid); switch_status_t status = SWITCH_STATUS_SUCCESS; QSharedPointer call = _active_calls.value(uuid); + + if (call.isNull()) + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "We don't have a call object for B leg on event %s.\n", switch_event_name(event->event_id)); + qDebug() << _active_calls.keys(); + printEventHeaders(event); + return SWITCH_STATUS_FALSE; + } + /* Inbound call */ if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND) { diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index c246964963..84ab54e83a 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -211,7 +211,9 @@ void MainWindow::callTableDoubleClick(QTableWidgetItem *item) return; } ui->hangupBtn->setEnabled(true); - lastCall.data()->setActive(false); + /* Last call was hungup and we are switching */ + if (!lastCall.isNull()) + lastCall.data()->setActive(false); call.data()->setActive(true); }