[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [sflphone-kde/abstractmodels] src: [ #25099 ] Add more checks for additionnal potention state corrup
From: Emmanuel Lepage Vallee <emmanuel.lepage () savoirfairelinux ! com>
Date: 2013-05-28 20:38:46
Message-ID: 20130528203846.81EFCA6067 () git ! kde ! org
[Download RAW message or body]
Git commit 1f724720ac91c02ba4d63eb7ce0c2e1ddfd1b527 by Emmanuel Lepage Vallee.
Committed on 28/05/2013 at 22:38.
Pushed by lepagevalleeemmanuel into branch 'abstractmodels'.
[ #25099 ] Add more checks for additionnal potention state corruption (warning, have \
false positives)
M +70 -17 src/lib/call.cpp
M +2 -1 src/lib/call.h
M +5 -2 src/lib/callmodel.cpp
M +2 -2 src/lib/typedefs.h
M +17 -0 src/sflphoneapplication.cpp
M +14 -3 src/widgets/callviewoverlaytoolbar.cpp
M +5 -1 src/widgets/categorizedtreeview.cpp
http://commits.kde.org/sflphone-kde/1f724720ac91c02ba4d63eb7ce0c2e1ddfd1b527
diff --git a/src/lib/call.cpp b/src/lib/call.cpp
index 857979e..196f6ad 100644
--- a/src/lib/call.cpp
+++ b/src/lib/call.cpp
@@ -108,7 +108,7 @@ const TypedStateMachine< TypedStateMachine< function , \
Call::DaemonState > , Cal /*TRANSFERT */ {{&Call::nothing , &Call::nothing \
, &Call::warning , &Call::nothing , &Call::stop , &Call::nothing \
}},/**/ /*TRANSFERT_HOLD */ {{&Call::nothing , &Call::nothing , &Call::warning \
, &Call::nothing , &Call::stop , &Call::nothing }},/**/ /*OVER \
*/ {{&Call::nothing , &Call::warning , &Call::warning , &Call::warning \
, &Call::stop , &Call::warning }},/**/
-/*ERROR */ {{&Call::nothing , &Call::nothing , &Call::nothing \
, &Call::nothing , &Call::stop , &Call::nothing }},/**/ +/*ERROR \
*/ {{&Call::error , &Call::error , &Call::error , &Call::error \
, &Call::stop , &Call::error }},/**/ /*CONF */ \
{{&Call::nothing , &Call::nothing , &Call::warning , &Call::nothing \
, &Call::stop , &Call::nothing }},/**/ /*CONF_HOLD */ \
{{&Call::nothing , &Call::nothing , &Call::warning , &Call::nothing \
, &Call::stop , &Call::nothing }},/**/ }};// \
@@ -146,7 +146,7 @@ void Call::setContactBackend(ContactBackend* be)
Call::Call(Call::State startState, const QString& callId, QString peerName, QString \
peerNumber, QString account) : HistoryTreeBackend(HistoryTreeBackend::Type::CALL), \
m_isConference(false),m_pStopTimeStamp(0),m_pStartTimeStamp(0), \
m_pContact(nullptr),m_pImModel(nullptr),m_LastContactCheck(-1),m_pTimer(nullptr),m_Recording(false),m_Account(account),
- m_PeerName(peerName),m_PeerPhoneNumber(peerNumber),m_CallId(callId)
+ m_PeerName(peerName),m_PeerPhoneNumber(peerNumber),m_CallId(callId),m_CurrentState(startState)
{
qRegisterMetaType<Call*>();
changeCurrentState(startState);
@@ -162,18 +162,16 @@ Call::Call(Call::State startState, const QString& callId, \
QString peerName, QStr ///Destructor
Call::~Call()
{
- //if (m_pStartTime) delete m_pStartTime ;
- //if (m_pStopTime) delete m_pStopTime ;
+ if (m_pTimer) delete m_pTimer;
this->disconnect();
}
///Constructor
Call::Call(QString confId, QString account): \
HistoryTreeBackend(HistoryTreeBackend::Type::CALL), \
m_isConference(false),
- m_pStopTimeStamp(0),m_pStartTimeStamp(0),m_pContact(nullptr),m_pImModel(nullptr),m_ConfId(confId),m_Account(account)
+ m_pStopTimeStamp(0),m_pStartTimeStamp(0),m_pContact(nullptr),m_pImModel(nullptr),m_ConfId(confId),m_Account(account),m_CurrentState(Call::State::CONFERENCE),
+ m_pTimer(nullptr)
{
m_isConference = m_ConfId.isEmpty();
-// this->m_ConfId = confId ;
-// this->m_Account = account ;
if (m_isConference) {
time_t curTime;
@@ -401,8 +399,9 @@ const QString Call::toHumanStateName(const Call::State cur)
case Call::State::CONFERENCE_HOLD:
return ( "Conference (hold)" );
case Call::State::COUNT:
+ return "ERROR";
default:
- return "";
+ return QString::number(static_cast<int>(cur));
}
}
@@ -654,17 +653,24 @@ Call::State Call::stateChanged(const QString& newStateName)
qDebug() << "Error: Invalid state change";
return Call::State::FAILURE;
}
+
try {
changeCurrentState(stateChangedStateMap[m_CurrentState][dcs]);
}
catch(Call::State state) {
- qDebug() << "State change failed" << state;
+ qDebug() << "State change failed (stateChangedStateMap)" << state;
m_CurrentState = Call::State::ERROR;
emit changed();
return m_CurrentState;
}
catch(Call::DaemonState state) {
- qDebug() << "State change failed" << state;
+ qDebug() << "State change failed (stateChangedStateMap)" << state;
+ m_CurrentState = Call::State::ERROR;
+ emit changed();
+ return m_CurrentState;
+ }
+ catch (...) {
+ qDebug() << "State change failed (stateChangedStateMap) other";;
m_CurrentState = Call::State::ERROR;
emit changed();
return m_CurrentState;
@@ -675,7 +681,28 @@ Call::State Call::stateChanged(const QString& newStateName)
if (details[CALL_PEER_NAME] != m_PeerName)
m_PeerName = details[CALL_PEER_NAME];
- (this->*(stateChangedFunctionMap[previousState][dcs]))();
+ try {
+ (this->*(stateChangedFunctionMap[previousState][dcs]))();
+ }
+ catch(Call::State state) {
+ qDebug() << "State change failed (stateChangedFunctionMap)" << state;
+ m_CurrentState = Call::State::ERROR;
+ emit changed();
+ return m_CurrentState;
+ }
+ catch(Call::DaemonState state) {
+ qDebug() << "State change failed (stateChangedFunctionMap)" << state;
+ m_CurrentState = Call::State::ERROR;
+ emit changed();
+ return m_CurrentState;
+ }
+ catch (...) {
+ qDebug() << "State change failed (stateChangedFunctionMap) other";;
+ m_CurrentState = Call::State::ERROR;
+ emit changed();
+ return m_CurrentState;
+ }
+
}
else {
//Until now, it does not worth using stateChangedStateMap, conferences are \
quite simple @@ -700,26 +727,39 @@ Call::State Call::actionPerformed(Call::Action \
action) changeCurrentState(actionPerformedStateMap[previousState][action]);
}
catch(Call::State state) {
- qDebug() << "State change failed" << state;
+ qDebug() << "State change failed (actionPerformedStateMap)" << state;
m_CurrentState = Call::State::ERROR;
emit changed();
- return Call::State::FAILURE;
+ return Call::State::ERROR;
}
+ catch (...) {
+ qDebug() << "State change failed (actionPerformedStateMap) other";;
+ m_CurrentState = Call::State::ERROR;
+ emit changed();
+ return m_CurrentState;
+ }
+
//execute the action associated with this transition
try {
(this->*(actionPerformedFunctionMap[previousState][action]))();
}
catch(Call::State state) {
- qDebug() << "State change failed" << state;
+ qDebug() << "State change failed (actionPerformedFunctionMap)" << state;
m_CurrentState = Call::State::ERROR;
emit changed();
- return Call::State::FAILURE;
+ return Call::State::ERROR;
}
catch(Call::Action action) {
- qDebug() << "State change failed" << action;
+ qDebug() << "State change failed (actionPerformedFunctionMap)" << action;
m_CurrentState = Call::State::ERROR;
emit changed();
- return Call::State::FAILURE;
+ return Call::State::ERROR;
+ }
+ catch (...) {
+ qDebug() << "State change failed (actionPerformedFunctionMap) other";;
+ m_CurrentState = Call::State::ERROR;
+ emit changed();
+ return m_CurrentState;
}
qDebug() << "Calling action " << action << " on call with state " << \
previousState << ". Become " << m_CurrentState; return m_CurrentState;
@@ -728,6 +768,12 @@ Call::State Call::actionPerformed(Call::Action action)
///Change the state
void Call::changeCurrentState(Call::State newState)
{
+ if (newState == Call::State::COUNT) {
+ qDebug() << "Error: Call reach invalid state";
+ m_CurrentState = Call::State::ERROR;
+ throw newState;
+ }
+
m_CurrentState = newState;
emit changed();
@@ -762,6 +808,13 @@ void Call::nothing()
}
+void Call::error()
+{
+ throw QString("There was an error handling your call, please restart SFLPhone.Is \
you encounter this problem often, \ + please open SFLPhone-KDE in a terminal and \
send this last 100 lines before this message in a bug report at \ + \
https://projects.savoirfairelinux.com/projects/sflphone/issues"); +}
+
///Accept the call
void Call::accept()
{
diff --git a/src/lib/call.h b/src/lib/call.h
index ed44a6a..e8d5f98 100644
--- a/src/lib/call.h
+++ b/src/lib/call.h
@@ -258,7 +258,7 @@ private:
QString m_CallNumber ;
static ContactBackend* m_pContactBackend;
bool m_isConference ;
- Call::State m_CurrentState ;
+ Call::State m_CurrentState ;
bool m_Recording ;
static Call* m_sSelectedCall ;
Contact* m_pContact ;
@@ -310,6 +310,7 @@ private:
// See actionPerformedFunctionMap and stateChangedFunctionMap
// to know when it is called.
void nothing ();
+ void error () __attribute__ ((noreturn));
void accept ();
void refuse ();
void acceptTransf ();
diff --git a/src/lib/callmodel.cpp b/src/lib/callmodel.cpp
index a7bde7a..40ba2e4 100644
--- a/src/lib/callmodel.cpp
+++ b/src/lib/callmodel.cpp
@@ -497,8 +497,11 @@ QVariant CallModel::data( const QModelIndex& idx, int role) \
const Call* call = nullptr;
if (!idx.parent().isValid() && m_lInternalModel[idx.row()])
call = m_lInternalModel[idx.row()]->call_real;
- else if (idx.parent().isValid() && m_lInternalModel.size() > idx.parent().row() \
&& m_lInternalModel[idx.parent().row()]->m_lChildren.size() > \
idx.row())
- call = m_lInternalModel[idx.parent().row()]->m_lChildren[idx.row()]->call_real;
+ else if (idx.parent().isValid() && m_lInternalModel.size() > idx.parent().row()) \
{ + InternalStruct* intList = m_lInternalModel[idx.parent().row()];
+ if (intList->m_lChildren.size() > idx.row() && \
intList->m_lChildren[idx.row()]) + call = \
intList->m_lChildren[idx.row()]->call_real; + }
return call?call->getRoleData((Call::Role)role):QVariant();
}
diff --git a/src/lib/typedefs.h b/src/lib/typedefs.h
index d7c69db..891b7ad 100644
--- a/src/lib/typedefs.h
+++ b/src/lib/typedefs.h
@@ -38,7 +38,7 @@ struct TypedStateMachine
T& operator[](E v) {
if (size_t(v) >= size_t(E::COUNT)) {
- qDebug() << "State Machine Out of Bound";
+ qDebug() << "State Machine Out of Bound" << size_t(v);
throw v;
}
return _data[size_t(v)];
@@ -46,7 +46,7 @@ struct TypedStateMachine
const T& operator[](E v) const {
if (size_t(v) >= size_t(E::COUNT)) {
- qDebug() << "State Machine Out of Bound";
+ qDebug() << "State Machine Out of Bound" << size_t(v);
throw v;
}
return _data[size_t(v)];
diff --git a/src/sflphoneapplication.cpp b/src/sflphoneapplication.cpp
index 801cc4f..5b75b5f 100644
--- a/src/sflphoneapplication.cpp
+++ b/src/sflphoneapplication.cpp
@@ -38,6 +38,7 @@
#include "sflphone.h"
#include "errormessage.h"
#include "lib/sflphone_const.h"
+#include "lib/call.h"
//Other
#include <unistd.h>
@@ -159,6 +160,22 @@ bool SFLPhoneApplication::notify (QObject* receiver, QEvent* e)
return KUniqueApplication::notify(receiver,e);
#endif
}
+ catch (Call::State state) {
+ kDebug() << ErrorMessage::GENERIC_ERROR << "CallState" << state;
+ QTimer::singleShot(2500,SFLPhone::app(),SLOT(timeout()));
+ }
+ catch (Call::Action state) {
+ kDebug() << ErrorMessage::GENERIC_ERROR << "Call Action" << state;
+ QTimer::singleShot(2500,SFLPhone::app(),SLOT(timeout()));
+ }
+ catch (Call::DaemonState state) {
+ kDebug() << ErrorMessage::GENERIC_ERROR << "Call DaemonState" << state;
+ QTimer::singleShot(2500,SFLPhone::app(),SLOT(timeout()));
+ }
+ catch (const QString& errorMessage) {
+ KMessageBox::error(SFLPhone::app(),errorMessage);
+ QTimer::singleShot(2500,SFLPhone::app(),SLOT(timeout()));
+ }
catch (...) {
kDebug() << ErrorMessage::GENERIC_ERROR;
KMessageBox::error(SFLPhone::app(),ErrorMessage::GENERIC_ERROR);
diff --git a/src/widgets/callviewoverlaytoolbar.cpp \
b/src/widgets/callviewoverlaytoolbar.cpp index 1699a33..bbeba40 100644
--- a/src/widgets/callviewoverlaytoolbar.cpp
+++ b/src/widgets/callviewoverlaytoolbar.cpp
@@ -25,7 +25,7 @@
#include <QtSvg/QSvgRenderer>
#include <QtGui/QHBoxLayout>
#include <QtGui/QStyle>
-#include <QDebug> //TODO remove
+#include <KDebug> //TODO remove
//KDE
#include <KStandardDirs>
@@ -155,8 +155,19 @@ void CallViewOverlayToolbar::updateState()
manager->setBottomMargin(53);
char act_counter = 0;
for (int i = 0;i<9;i++) {
- m_hButtons[ i ]->setVisible(visibility[ static_cast<ActionButton>(i) \
][state]);
- act_counter += visibility[ static_cast<ActionButton>(i) ][state];
+ try {
+ m_hButtons[ i ]->setVisible(visibility[ static_cast<ActionButton>(i) \
][state]); + act_counter += visibility[ static_cast<ActionButton>(i) \
][state]; + }
+ catch (Call::State state) {
+ qDebug() << "CallViewOverlayToolbar is out of bound (state)" << state;
+ }
+ catch (ActionButton btn) {
+ kDebug() << "CallViewOverlayToolbar is out of bound (Action)" << \
(int)btn; + }
+ catch (...) {
+ kDebug() << "CallViewOverlayToolbar is out of bound (Other)";
+ }
}
if (!act_counter)
setVisible(false);
diff --git a/src/widgets/categorizedtreeview.cpp \
b/src/widgets/categorizedtreeview.cpp index 1694524..ba221ee 100644
--- a/src/widgets/categorizedtreeview.cpp
+++ b/src/widgets/categorizedtreeview.cpp
@@ -31,6 +31,7 @@
//SFLPhone
#include <delegates/conferencedelegate.h>
#include <klib/tipmanager.h>
+#include <lib/call.h>
#include <widgets/tips/tipcollection.h>
///Constructor
@@ -151,7 +152,10 @@ void CategorizedTreeView::startDrag(Qt::DropActions \
supportedActions)
bool CategorizedTreeView::edit(const QModelIndex& index, EditTrigger trigger, \
QEvent* event) {
- if (state() == QAbstractItemView::EditingState)
+ if (state() == QAbstractItemView::EditingState) {
+ if (index.data(Call::Role::CallState).toInt() != size_t(Call::State::DIALING))
+ return false;
return true;
+ }
return QTreeView::edit(index,trigger,event);
}
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic