Commit 2100f1c4 authored by Olivier SOLDANO's avatar Olivier SOLDANO Committed by Andreas Traczyk

Fix first wizard hangup

when closing the first wizard without creating an account
was resulting in a hang up of the application.
this was due to a exit(0) called in the middle of nowhere.
This patch revises a bit the architecture to allow the information to
reach the main and close the app correctly. (passing by return values
because signals do not work without objects).

Change-Id: I8d4b1bcdcf2646342fd7015509ef7773ca4b09d1
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent c1ca2dfb
......@@ -118,8 +118,6 @@ CallWidget::CallWidget(QWidget* parent) :
ui->contactRequestList->setItemDelegate(new ContactRequestItemDelegate());
findRingAccount();
setupOutOfCallIM();
ui->smartList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->smartList, &SmartList::btnVideoClicked, this, &CallWidget::btnComBarVideoClicked);
......@@ -193,6 +191,8 @@ CallWidget::CallWidget(QWidget* parent) :
} catch (const std::exception& e) {
qDebug() << "INIT ERROR" << e.what();
}
setupOutOfCallIM();
}
CallWidget::~CallWidget()
......@@ -382,11 +382,10 @@ void CallWidget::setupQRCode(QString ringID)
ui->qrLabel->setPixmap(QPixmap::fromImage(result.scaled(QSize(qrSize_, qrSize_), Qt::KeepAspectRatio)));
}
void
bool
CallWidget::findRingAccount()
{
bool ringAccountFound = false;
auto a_count = AccountModel::instance().rowCount();
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance().index(i, 0);
......@@ -402,13 +401,18 @@ CallWidget::findRingAccount()
}
}
}
if (!ringAccountFound) {
WizardDialog wizardDialog;
wizardDialog.exec();
if (wizardDialog.result() != QDialog::Accepted) {
return false;
}
}
ui->currentAccountWidget->update();
return true;
}
void
......
......@@ -53,7 +53,7 @@ public:
explicit CallWidget(QWidget* parent = 0);
~CallWidget();
void atExit();
void findRingAccount();
bool findRingAccount();
public slots:
void settingsButtonClicked();
......
......@@ -157,6 +157,14 @@ main(int argc, char *argv[])
QCoreApplication::setOrganizationDomain("ring.cx");
QCoreApplication::setApplicationName("Ring");
QFontDatabase::addApplicationFont(":/images/FontAwesome.otf");
if (not MainWindow::instance().init()) {
return 1;
}
MainWindow::instance().createThumbBar();
if (not uri.isEmpty()) {
startMinimized = false;
MainWindow::instance().onRingEvent(uri);
......@@ -169,7 +177,6 @@ main(int argc, char *argv[])
MainWindow::instance().hide();
}
MainWindow::instance().createThumbBar();
#ifdef URI_PROTOCOL
QObject::connect(shmClient, SIGNAL(RingEvent(QString)), &MainWindow::instance(), SLOT(onRingEvent(QString)));
......@@ -182,7 +189,5 @@ main(int argc, char *argv[])
});
#endif
QFontDatabase::addApplicationFont(":/images/FontAwesome.otf");
return a.exec();
}
......@@ -128,6 +128,12 @@ MainWindow::~MainWindow()
delete ui;
}
bool
MainWindow::init()
{
return ui->callwidget->findRingAccount();
}
void
MainWindow::onRingEvent(const QString& uri)
{
......
......@@ -45,6 +45,7 @@ public:
return *instance;
}
void createThumbBar();
bool init();
protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result);
......
......@@ -178,10 +178,11 @@ void
WizardDialog::closeEvent(QCloseEvent* event)
{
Q_UNUSED(event);
if (wizardMode_ == WIZARD)
exit(0);
else
if (wizardMode_ == WIZARD){
done(QDialog::Rejected);
} else {
QDialog::closeEvent(event);
}
}
void
......
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