Commit 15aaff8a authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): use Q_CHECK_PTR when it's possible

parent 2e1a802d
......@@ -64,7 +64,7 @@ private:
) override {
if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
emit mAssistant->loginStatusChanged("");
} else {
......@@ -86,7 +86,7 @@ private:
) {
if (creator->getEmail().empty()) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
}
emit mAssistant->activateStatusChanged("");
......@@ -105,7 +105,7 @@ private:
) override {
if (status == linphone::AccountCreatorStatusAccountActivated) {
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
emit mAssistant->activateStatusChanged("");
} else {
......
......@@ -38,7 +38,7 @@ using namespace std;
// =============================================================================
CallModel::CallModel (shared_ptr<linphone::Call> call) {
Q_ASSERT(call != nullptr);
Q_CHECK_PTR(call);
mCall = call;
mCall->setData("call-model", *this);
......
......@@ -31,7 +31,7 @@ using namespace std;
ConferenceHelperModel::ConferenceAddModel::ConferenceAddModel (QObject *parent) : QAbstractListModel(parent) {
mConferenceHelperModel = qobject_cast<ConferenceHelperModel *>(parent);
Q_ASSERT(mConferenceHelperModel != nullptr);
Q_CHECK_PTR(mConferenceHelperModel);
CoreManager *coreManager = CoreManager::getInstance();
......@@ -134,7 +134,7 @@ void ConferenceHelperModel::ConferenceAddModel::update () {
list<shared_ptr<linphone::Address> > linphoneAddresses;
for (const auto &map : mRefs) {
shared_ptr<linphone::Address> linphoneAddress = map->value("__linphoneAddress").value<shared_ptr<linphone::Address> >();
Q_ASSERT(linphoneAddress != nullptr);
Q_CHECK_PTR(linphoneAddress);
linphoneAddresses.push_back(linphoneAddress);
}
......
......@@ -31,7 +31,7 @@ using namespace std;
// =============================================================================
ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linphoneFriend) : QObject(parent) {
Q_ASSERT(linphoneFriend != nullptr);
Q_CHECK_PTR(linphoneFriend);
mLinphoneFriend = linphoneFriend;
mLinphoneFriend->setData("contact-model", *this);
......@@ -40,8 +40,8 @@ ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linpho
}
ContactModel::ContactModel (QObject *parent, VcardModel *vcardModel) : QObject(parent) {
Q_ASSERT(vcardModel != nullptr);
Q_ASSERT(vcardModel->mVcard != nullptr);
Q_CHECK_PTR(vcardModel);
Q_CHECK_PTR(vcardModel->mVcard);
Q_ASSERT(!vcardModel->mIsReadOnly);
mLinphoneFriend = linphone::Friend::newFromVcard(vcardModel->mVcard);
......@@ -86,7 +86,7 @@ void ContactModel::setVcardModel (VcardModel *vcardModel) {
}
void ContactModel::setVcardModelInternal (VcardModel *vcardModel) {
Q_ASSERT(vcardModel != nullptr);
Q_CHECK_PTR(vcardModel);
Q_ASSERT(vcardModel != mVcardModel);
mVcardModel = vcardModel;
......@@ -100,7 +100,7 @@ void ContactModel::setVcardModelInternal (VcardModel *vcardModel) {
}
void ContactModel::updateSipAddresses (VcardModel *oldVcardModel) {
Q_ASSERT(oldVcardModel != nullptr);
Q_CHECK_PTR(oldVcardModel);
QVariantList oldSipAddresses = oldVcardModel->getSipAddresses();
QVariantList sipAddresses = mVcardModel->getSipAddresses();
......@@ -139,7 +139,7 @@ next:
// -----------------------------------------------------------------------------
void ContactModel::mergeVcardModel (VcardModel *vcardModel) {
Q_ASSERT(vcardModel != nullptr);
Q_CHECK_PTR(vcardModel);
qInfo() << QStringLiteral("Merge vcard into contact:") << this << vcardModel;
......@@ -184,8 +184,8 @@ void ContactModel::mergeVcardModel (VcardModel *vcardModel) {
VcardModel *ContactModel::cloneVcardModel () const {
shared_ptr<linphone::Vcard> vcard = mVcardModel->mVcard->clone();
Q_ASSERT(vcard != nullptr);
Q_ASSERT(vcard->getVcard() != nullptr);
Q_CHECK_PTR(vcard);
Q_CHECK_PTR(vcard->getVcard());
mLinphoneFriend->edit();
......
......@@ -112,7 +112,7 @@ static string interpretSipAddress (const QString &sipAddress) {
// -----------------------------------------------------------------------------
VcardModel::VcardModel (shared_ptr<linphone::Vcard> vcard, bool isReadOnly) {
Q_ASSERT(vcard != nullptr);
Q_CHECK_PTR(vcard);
mVcard = vcard;
mIsReadOnly = isReadOnly;
}
......
......@@ -86,7 +86,7 @@ void CoreManager::uninit () {
// -----------------------------------------------------------------------------
VcardModel *CoreManager::createDetachedVcardModel () {
VcardModel *CoreManager::createDetachedVcardModel () const {
VcardModel *vcardModel = new VcardModel(linphone::Factory::get()->createVcard(), false);
qInfo() << QStringLiteral("Create detached vcard:") << vcardModel;
return vcardModel;
......
......@@ -49,12 +49,12 @@ public:
~CoreManager () = default;
std::shared_ptr<linphone::Core> getCore () {
Q_ASSERT(mCore != nullptr);
Q_CHECK_PTR(mCore);
return mCore;
}
std::shared_ptr<CoreHandlers> getHandlers () {
Q_ASSERT(mHandlers != nullptr);
Q_CHECK_PTR(mHandlers);
return mHandlers;
}
......@@ -75,27 +75,27 @@ public:
// ---------------------------------------------------------------------------
CallsListModel *getCallsListModel () const {
Q_ASSERT(mCallsListModel != nullptr);
Q_CHECK_PTR(mCallsListModel);
return mCallsListModel;
}
ContactsListModel *getContactsListModel () const {
Q_ASSERT(mContactsListModel != nullptr);
Q_CHECK_PTR(mContactsListModel);
return mContactsListModel;
}
SipAddressesModel *getSipAddressesModel () const {
Q_ASSERT(mSipAddressesModel != nullptr);
Q_CHECK_PTR(mSipAddressesModel);
return mSipAddressesModel;
}
SettingsModel *getSettingsModel () const {
Q_ASSERT(mSettingsModel != nullptr);
Q_CHECK_PTR(mSettingsModel);
return mSettingsModel;
}
AccountSettingsModel *getAccountSettingsModel () const {
Q_ASSERT(mAccountSettingsModel != nullptr);
Q_CHECK_PTR(mAccountSettingsModel);
return mAccountSettingsModel;
}
......@@ -107,7 +107,7 @@ public:
static void uninit ();
static CoreManager *getInstance () {
Q_ASSERT(mInstance != nullptr);
Q_CHECK_PTR(mInstance);
return mInstance;
}
......@@ -115,10 +115,12 @@ public:
// Must be used in a qml scene.
// Warning: The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default.
Q_INVOKABLE VcardModel *createDetachedVcardModel ();
Q_INVOKABLE VcardModel *createDetachedVcardModel () const;
Q_INVOKABLE void forceRefreshRegisters ();
Q_INVOKABLE void sendLogs () const;
signals:
void coreCreated ();
void coreStarted ();
......
......@@ -134,10 +134,10 @@ QObject *Notifier::createNotification (Notifier::NotificationType type) {
{
QQuickWindow *window = instance->findChild<QQuickWindow *>(NOTIFICATION_PROPERTY_WINDOW);
Q_ASSERT(window != nullptr);
Q_CHECK_PTR(window);
QScreen *screen = window->screen();
Q_ASSERT(screen != nullptr);
Q_CHECK_PTR(screen);
QRect geometry = screen->availableGeometry();
......
......@@ -60,7 +60,7 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
// -----------------------------------------------------------------------------
bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
......@@ -83,7 +83,7 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::Pr
}
QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
QVariantMap map;
......@@ -114,7 +114,7 @@ void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::Pro
}
void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
CoreManager::getInstance()->getCore()->removeProxyConfig(proxyConfig);
emit accountSettingsUpdated();
......@@ -124,7 +124,7 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
const shared_ptr<linphone::ProxyConfig> &proxyConfig,
const QVariantMap &data
) {
Q_ASSERT(proxyConfig != nullptr);
Q_CHECK_PTR(proxyConfig);
QString literal = data["sipAddress"].toString();
......
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