fixed reloading the current page twice in a row
This commit is contained in:
parent
616c462c5c
commit
b3ca555c89
2 changed files with 21 additions and 14 deletions
|
@ -127,8 +127,6 @@ void DockWindow::onQuit()
|
|||
{
|
||||
TRACEFUNC;
|
||||
|
||||
m_quiting = true;
|
||||
|
||||
IF_ASSERT_FAILED(m_currentPage) {
|
||||
return;
|
||||
}
|
||||
|
@ -171,16 +169,12 @@ void DockWindow::init()
|
|||
dockWindowProvider()->init(this);
|
||||
|
||||
uiConfiguration()->windowGeometryChanged().onNotify(this, [this]() {
|
||||
if (!m_quiting) {
|
||||
updatePageState();
|
||||
}
|
||||
reloadCurrentPage();
|
||||
});
|
||||
|
||||
workspaceManager()->currentWorkspaceAboutToBeChanged().onNotify(this, [this]() {
|
||||
if (DockPageView* page = currentPage()) {
|
||||
m_workspaceChanging = true;
|
||||
if (const DockPageView* page = currentPage()) {
|
||||
savePageState(page->objectName());
|
||||
m_workspaceChanging = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -291,11 +285,15 @@ void DockWindow::restoreDefaultLayout()
|
|||
}
|
||||
}
|
||||
|
||||
m_reloadCurrentPageAllowed = false;
|
||||
for (const DockPageView* page : m_pages.list()) {
|
||||
uiConfiguration()->setPageState(page->objectName(), QByteArray());
|
||||
}
|
||||
|
||||
uiConfiguration()->setWindowGeometry(QByteArray());
|
||||
m_reloadCurrentPageAllowed = true;
|
||||
|
||||
reloadCurrentPage();
|
||||
}
|
||||
|
||||
void DockWindow::loadPageContent(const DockPageView* page)
|
||||
|
@ -500,7 +498,9 @@ void DockWindow::saveGeometry()
|
|||
/// and restore only the application geometry.
|
||||
/// Therefore, for correct operation after saving or restoring geometry,
|
||||
/// it is necessary to apply the appropriate method for the state.
|
||||
m_reloadCurrentPageAllowed = false;
|
||||
uiConfiguration()->setWindowGeometry(windowState());
|
||||
m_reloadCurrentPageAllowed = true;
|
||||
}
|
||||
|
||||
void DockWindow::restoreGeometry()
|
||||
|
@ -522,7 +522,9 @@ void DockWindow::savePageState(const QString& pageName)
|
|||
{
|
||||
TRACEFUNC;
|
||||
|
||||
m_reloadCurrentPageAllowed = false;
|
||||
uiConfiguration()->setPageState(pageName, windowState());
|
||||
m_reloadCurrentPageAllowed = true;
|
||||
}
|
||||
|
||||
void DockWindow::restorePageState(const QString& pageName)
|
||||
|
@ -540,8 +542,8 @@ void DockWindow::restorePageState(const QString& pageName)
|
|||
if (!pageStateValNt.notification.isConnected()) {
|
||||
pageStateValNt.notification.onNotify(this, [this, pageName]() {
|
||||
bool isCurrentPage = m_currentPage && (m_currentPage->objectName() == pageName);
|
||||
if (isCurrentPage && !m_quiting && !m_workspaceChanging) {
|
||||
updatePageState();
|
||||
if (isCurrentPage) {
|
||||
reloadCurrentPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -570,8 +572,14 @@ QByteArray DockWindow::windowState() const
|
|||
return layoutSaver.serializeLayout();
|
||||
}
|
||||
|
||||
void DockWindow::updatePageState()
|
||||
void DockWindow::reloadCurrentPage()
|
||||
{
|
||||
if (!m_reloadCurrentPageAllowed) {
|
||||
return;
|
||||
}
|
||||
|
||||
TRACEFUNC;
|
||||
|
||||
QString currentPageUriBackup = currentPageUri();
|
||||
|
||||
/// NOTE: for reset geometry
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
void savePageState(const QString& pageName);
|
||||
void restorePageState(const QString& pageName);
|
||||
|
||||
void updatePageState();
|
||||
void reloadCurrentPage();
|
||||
bool restoreLayout(const QByteArray& layout, bool restoreRelativeToMainWindow = false);
|
||||
|
||||
void initDocks(DockPageView* page);
|
||||
|
@ -137,8 +137,7 @@ private:
|
|||
async::Channel<QStringList> m_docksOpenStatusChanged;
|
||||
|
||||
bool m_hasGeometryBeenRestored = false;
|
||||
bool m_quiting = false;
|
||||
bool m_workspaceChanging = false;
|
||||
bool m_reloadCurrentPageAllowed = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue