Commit 4ba5c829 authored by Edric Milaret's avatar Edric Milaret

transfer: fix segfault in ui

Issue: #81134
Change-Id: I16ba4e87442326ab1c2db97838ea0caaa32ade31
parent 889fe05f
......@@ -24,16 +24,13 @@
TransferDialog::TransferDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::TransferDialog)
ui(new Ui::TransferDialog),
activeProxy_(nullptr)
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
auto activeProxy = new ActiveCallsProxyModel(CallModel::instance());
ui->activeCallsView->setModel(activeProxy);
ui->activeCallsView->clearSelection();
}
TransferDialog::~TransferDialog()
......@@ -48,11 +45,19 @@ TransferDialog::showEvent(QShowEvent *event)
ui->numberBar->clear();
selectedCall_ = nullptr;
if (not activeProxy_) {
activeProxy_ = new ActiveCallsProxyModel(CallModel::instance());
activeProxy_->setDynamicSortFilter(false);
}
ui->activeCallsView->setModel(activeProxy_);
ui->activeCallsView->clearSelection();
}
void
TransferDialog::on_transferButton_clicked()
{
removeProxyModel();
auto callList = CallModel::instance()->getActiveCalls();
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
......@@ -68,15 +73,25 @@ TransferDialog::on_transferButton_clicked()
}
}
void
TransferDialog::removeProxyModel()
{
//This prevent a crash happening in Qt5.5 in QSortFilterProxyModel
ui->activeCallsView->setModel(nullptr);
}
void
TransferDialog::on_activeCallsView_doubleClicked(const QModelIndex &index)
{
Q_UNUSED(index)
removeProxyModel();
auto callList = CallModel::instance()->getActiveCalls();
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
auto selectedCall = CallModel::instance()->getCall(index);
if (c != selectedCall) {
CallModel::instance()->attendedTransfer(c, selectedCall);
if (c != selectedCall_) {
CallModel::instance()->attendedTransfer(c, selectedCall_);
this->close();
return;
}
......
......@@ -36,8 +36,13 @@ public:
}
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
return sourceModel()->index(source_row,0,source_parent)
.data(static_cast<int>(Call::Role::State)).value<Call::State>() != Call::State::CURRENT;
if (not sourceModel() || source_parent.isValid())
return false;
auto idx = sourceModel()->index(source_row,0,source_parent);
if (not idx.isValid())
return false;
return idx.data(static_cast<int>(Call::Role::State))
.value<Call::State>() != Call::State::CURRENT;
}
};
......@@ -61,5 +66,8 @@ private slots:
private:
Ui::TransferDialog *ui;
Call *selectedCall_;
ActiveCallsProxyModel *activeProxy_;
void removeProxyModel();
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment