Skip to content
Snippets Groups Projects
Commit b8b5e2f5 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin
Browse files

tests: fix some possible crashes

Prevents some uncaught exceptions that could occur depending on test implementation.

Gitlab: #899
Change-Id: I5b06c270c924071f331e20f3b894a4bb80228137
parent 8dc0be11
No related branches found
Tags beta/20230411
No related merge requests found
...@@ -51,8 +51,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* ...@@ -51,8 +51,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject*
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, overlayModel_.get(), "CallOverlayModel"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, overlayModel_.get(), "CallOverlayModel");
accountId_ = lrcInstance_->get_currentAccountId(); accountId_ = lrcInstance_->get_currentAccountId();
if (!accountId_.isEmpty()) connectCallModel(accountId_);
connectCallModel(accountId_);
connect(&lrcInstance_->behaviorController(), connect(&lrcInstance_->behaviorController(),
&BehaviorController::showIncomingCallView, &BehaviorController::showIncomingCallView,
...@@ -471,6 +470,9 @@ CallAdapter::showNotification(const QString& accountId, const QString& convUid) ...@@ -471,6 +470,9 @@ CallAdapter::showNotification(const QString& accountId, const QString& convUid)
void void
CallAdapter::connectCallModel(const QString& accountId) CallAdapter::connectCallModel(const QString& accountId)
{ {
if (accountId.isEmpty())
return;
auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId); auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
connect(accInfo.callModel.get(), connect(accInfo.callModel.get(),
&CallModel::callStarted, &CallModel::callStarted,
......
...@@ -44,7 +44,12 @@ LRCInstance::LRCInstance(migrateCallback willMigrateCb, ...@@ -44,7 +44,12 @@ LRCInstance::LRCInstance(migrateCallback willMigrateCb,
accountModel().setTopAccount(currentAccountId_); accountModel().setTopAccount(currentAccountId_);
Q_EMIT accountListChanged(); Q_EMIT accountListChanged();
auto profileInfo = getCurrentAccountInfo().profileInfo; profile::Info profileInfo;
try {
profileInfo = getCurrentAccountInfo().profileInfo;
} catch (...) {
return;
}
// update type // update type
set_currentAccountType(profileInfo.type); set_currentAccountType(profileInfo.type);
......
...@@ -49,7 +49,12 @@ public: ...@@ -49,7 +49,12 @@ public:
: muteDring_(muteDring) : muteDring_(muteDring)
{} {}
void init() public Q_SLOTS:
/*
* Called once before qmlEngineAvailable.
*/
void applicationAvailable()
{ {
connectivityMonitor_.reset(new ConnectivityMonitor(this)); connectivityMonitor_.reset(new ConnectivityMonitor(this));
settingsManager_.reset(new AppSettingsManager(this)); settingsManager_.reset(new AppSettingsManager(this));
...@@ -66,28 +71,6 @@ public: ...@@ -66,28 +71,6 @@ public:
lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/"; lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/";
} }
void registerQmlTypes(QQmlEngine* engine)
{
// Expose custom types to the QML engine.
Utils::registerTypes(engine,
systemTray_.get(),
lrcInstance_.get(),
settingsManager_.get(),
previewEngine_.get(),
&screenInfo_,
this);
}
public Q_SLOTS:
/*
* Called once before qmlEngineAvailable.
*/
void applicationAvailable()
{
init();
}
/* /*
* Called when the QML engine is available. Any import paths, plugin paths, * Called when the QML engine is available. Any import paths, plugin paths,
* and extra file selectors will have been set on the engine by this point. * and extra file selectors will have been set on the engine by this point.
...@@ -100,7 +83,17 @@ public Q_SLOTS: ...@@ -100,7 +83,17 @@ public Q_SLOTS:
*/ */
void qmlEngineAvailable(QQmlEngine* engine) void qmlEngineAvailable(QQmlEngine* engine)
{ {
registerQmlTypes(engine); lrcInstance_->set_currentAccountId();
// Expose custom types to the QML engine.
Utils::registerTypes(engine,
systemTray_.get(),
lrcInstance_.get(),
settingsManager_.get(),
previewEngine_.get(),
&screenInfo_,
this);
auto videoProvider = new VideoProvider(lrcInstance_->avModel(), this); auto videoProvider = new VideoProvider(lrcInstance_->avModel(), this);
engine->rootContext()->setContextProperty("videoProvider", videoProvider); engine->rootContext()->setContextProperty("videoProvider", videoProvider);
#ifdef WITH_WEBENGINE #ifdef WITH_WEBENGINE
...@@ -133,9 +126,14 @@ main(int argc, char** argv) ...@@ -133,9 +126,14 @@ main(int argc, char** argv)
{ {
QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
auto jamiDataDir = tempDir.absolutePath() + "\\jami_test\\jami"; auto jamiDataDir = tempDir.absolutePath() + "/jami_test/jami";
auto jamiConfigDir = tempDir.absolutePath() + "\\jami_test\\.config"; auto jamiConfigDir = tempDir.absolutePath() + "/jami_test/.config";
auto jamiCacheDir = tempDir.absolutePath() + "\\jami_test\\.cache"; auto jamiCacheDir = tempDir.absolutePath() + "/jami_test/.cache";
// Clean up the temp directories.
QDir(jamiDataDir).removeRecursively();
QDir(jamiConfigDir).removeRecursively();
QDir(jamiCacheDir).removeRecursively();
bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit()); bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit());
envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit()); envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment