- Fix freeze/crash on fullscreen : Reset renderer before getting a new one

- Fix crash when getting a Contactthat have not the key "contact-model"
- Fix crash on startup by a delay on core creation
This commit is contained in:
Julien Wadel 2021-03-18 22:32:20 +01:00
parent af2abde8b9
commit 1c0fb599c0
5 changed files with 19 additions and 13 deletions

View file

@ -58,15 +58,18 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
QQuickFramebufferObject::Renderer *Camera::createRenderer () const {
QQuickFramebufferObject::Renderer * renderer = NULL;
if(mIsPreview){
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(NULL);// Reset
renderer=(QQuickFramebufferObject::Renderer *)CoreManager::getInstance()->getCore()->getNativePreviewWindowId();
return renderer;
}else{
auto call = mCallModel->getCall();
if(call) renderer= (QQuickFramebufferObject::Renderer *) call->getNativeVideoWindowId();
if(!call || !renderer){
if(call){
call->setNativeVideoWindowId(NULL);// Reset
return (QQuickFramebufferObject::Renderer *) call->getNativeVideoWindowId();
}else{
CoreManager::getInstance()->getCore()->setNativeVideoWindowId(NULL);
return (QQuickFramebufferObject::Renderer *) CoreManager::getInstance()->getCore()->getNativeVideoWindowId();
}else
return renderer;
}
}
}

View file

@ -84,6 +84,7 @@ public:
QQuickFramebufferObject::Renderer *CameraPreview::createRenderer () const {
QQuickFramebufferObject::Renderer * renderer;
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(NULL);// Reset
renderer=(QQuickFramebufferObject::Renderer *)CoreManager::getInstance()->getCore()->getNativePreviewWindowId();
if(renderer)
return renderer;

View file

@ -217,7 +217,7 @@ void CoreHandlers::onNotifyPresenceReceived (
const shared_ptr<linphone::Friend> &linphoneFriend
) {
// Ignore friend without vcard because the `contact-model` data doesn't exist.
if (linphoneFriend->getVcard())
if (linphoneFriend->getVcard() && linphoneFriend->dataExists("contact-model"))
linphoneFriend->getData<ContactModel>("contact-model").refreshPresence();
}

View file

@ -71,7 +71,7 @@ namespace {
// -----------------------------------------------------------------------------
CoreManager *CoreManager::mInstance;
CoreManager *CoreManager::mInstance=nullptr;
CoreManager::CoreManager (QObject *parent, const QString &configPath) :
QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) {
@ -83,7 +83,9 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
QObject::connect(coreHandlers, &CoreHandlers::coreStarted, this, &CoreManager::initCoreManager, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::coreStopped, this, &CoreManager::stopIterate, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::logsUploadStateChanged, this, &CoreManager::handleLogsUploadStateChanged);
createLinphoneCore(configPath);
QTimer::singleShot(10, [this, configPath](){// Delay the creation in order to have the CoreManager instance set before
createLinphoneCore(configPath);
});
}
CoreManager::~CoreManager(){
@ -109,6 +111,9 @@ void CoreManager::initCoreManager(){
qInfo() << QStringLiteral("CoreManager initialized");
emit coreManagerInitialized();
}
CoreManager *CoreManager::getInstance (){
return mInstance;
}
shared_ptr<ChatModel> CoreManager::getChatModel (const QString &peerAddress, const QString &localAddress) {
if (peerAddress.isEmpty() || localAddress.isEmpty())

View file

@ -117,10 +117,7 @@ public:
return mAccountSettingsModel;
}
static CoreManager *getInstance () {
Q_CHECK_PTR(mInstance);
return mInstance;
}
static CoreManager *getInstance ();
// ---------------------------------------------------------------------------
// Initialization.
@ -151,7 +148,8 @@ public slots:
void initCoreManager();
void startIterate();
void stopIterate();
void setLastRemoteProvisioningState(const linphone::ConfiguringState& state);
void setLastRemoteProvisioningState(const linphone::ConfiguringState& state);
void createLinphoneCore (const QString &configPath);// In order to delay creation
signals:
void coreManagerInitialized ();
@ -171,7 +169,6 @@ private:
void setOtherPaths ();
void setResourcesPaths ();
void createLinphoneCore (const QString &configPath);
void migrate ();
QString getVersion () const;