Skip to content

Commit

Permalink
Merge pull request #984 from ONLYOFFICE/fix/updates_init
Browse files Browse the repository at this point in the history
Fix update initialization
  • Loading branch information
maxkadushkin authored Sep 29, 2023
2 parents f2742f4 + fc5f9bb commit 7ff6fdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
47 changes: 23 additions & 24 deletions win-linux/src/cascapplicationmanagerwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ CAscApplicationManagerWrapper::CAscApplicationManagerWrapper(CAscApplicationMana
m_queueToClose->setcallback(callback_);

m_themes = std::make_shared<CThemes>();

#ifdef _UPDMODULE
m_pUpdateManager = new CUpdateManager(this);
#endif
}

CAscApplicationManagerWrapper::~CAscApplicationManagerWrapper()
Expand Down Expand Up @@ -113,7 +109,8 @@ CAscApplicationManagerWrapper::~CAscApplicationManagerWrapper()
}
#if defined (_UPDMODULE)
// Start update installation
m_pUpdateManager->handleAppClose();
if (m_pUpdateManager)
m_pUpdateManager->handleAppClose();
#endif
// m_vecEditors.clear();
}
Expand Down Expand Up @@ -294,20 +291,22 @@ bool CAscApplicationManagerWrapper::processCommonEvent(NSEditorApi::CAscCefMenuE
} else
#ifdef _UPDMODULE
if ( !(cmd.find(L"updates:action") == std::wstring::npos) ) { // params: check, download, install, abort
const QString params = QString::fromStdWString(pData->get_Param());
if (params == "check") {
m_pUpdateManager->checkUpdates(true);
} else
if (params == "download") {
m_pUpdateManager->loadUpdates();
} else
if (params == "install") {
m_pUpdateManager->installUpdates();
} else
if (params == "abort") {
m_pUpdateManager->cancelLoading();
if (m_pUpdateManager) {
const QString params = QString::fromStdWString(pData->get_Param());
if (params == "check") {
m_pUpdateManager->checkUpdates(true);
} else
if (params == "download") {
m_pUpdateManager->loadUpdates();
} else
if (params == "install") {
m_pUpdateManager->installUpdates();
} else
if (params == "abort") {
m_pUpdateManager->cancelLoading();
}
return true;
}
return true;
} else
#endif
if ( cmd.compare(L"title:button") == 0 ) {
Expand Down Expand Up @@ -921,16 +920,15 @@ void CAscApplicationManagerWrapper::handleInputCmd(const std::vector<wstring>& v
void CAscApplicationManagerWrapper::onDocumentReady(int uid)
{
#ifdef _UPDMODULE
if (!m_pUpdateManager) {
m_pUpdateManager = new CUpdateManager(this);
m_pUpdateManager->launchIntervalStartTimer();
}
if (uid < 0) {
QTimer::singleShot(50, this, [=]() {
m_pUpdateManager->refreshStartPage();
});
}
static bool lock = false;
if (!lock) {
lock = true;
m_pUpdateManager->launchIntervalStartTimer();
}
#endif
}

Expand Down Expand Up @@ -1658,7 +1656,8 @@ bool CAscApplicationManagerWrapper::applySettings(const wstring& wstrjson)
}
#ifdef _UPDMODULE
if ( objRoot.contains("autoupdatemode") ) {
m_pUpdateManager->setNewUpdateSetting(objRoot["autoupdatemode"].toString());
if (m_pUpdateManager)
m_pUpdateManager->setNewUpdateSetting(objRoot["autoupdatemode"].toString());
}
#endif
} else {
Expand Down
2 changes: 1 addition & 1 deletion win-linux/src/cascapplicationmanagerwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private slots:
CAscApplicationManagerWrapper(CAscApplicationManagerWrapper_Private *);

#ifdef _UPDMODULE
CUpdateManager *m_pUpdateManager;
CUpdateManager *m_pUpdateManager = nullptr;
#endif
};

Expand Down

0 comments on commit 7ff6fdb

Please sign in to comment.