Commit 93e5bb17 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Fix views not created for stashed documents

If you have more than 1 stashed doc and you close kate, only one of the
stashed documents *might* get a view. The others won't. This change
fixes that.

This happened because when we created the viewmanager, we immediately
tried to register all the documents in the current viewspace and
destroyed this viewspace immediately afterwards when we restored the
viewspaces.

It is still partly broken i.e., the views for stashed docs are created
but the active view is incorrect because of how the config is restored
i.e., based on URLs, but untitled docs don't have URLs. But this can be
fixed later.
parent 3613fb4b
Pipeline #135047 passed with stage
in 2 minutes and 13 seconds
......@@ -33,6 +33,7 @@
#include <QFileDialog>
#include <QStyle>
#include <QTimer>
// END Includes
......@@ -46,9 +47,6 @@ KateViewManager::KateViewManager(QWidget *parentW, KateMainWindow *parent)
, m_minAge(0)
, m_guiMergedView(nullptr)
{
// while init
m_init = true;
// we don't allow full collapse, see bug 366014
setChildrenCollapsible(false);
......@@ -78,18 +76,21 @@ KateViewManager::KateViewManager(QWidget *parentW, KateMainWindow *parent)
connect(KateApp::self()->documentManager(), &KateDocManager::aboutToDeleteDocuments, this, &KateViewManager::aboutToDeleteDocuments);
connect(KateApp::self()->documentManager(), &KateDocManager::documentsDeleted, this, &KateViewManager::documentsDeleted);
// register all already existing documents
m_blockViewCreationAndActivation = true;
const auto &docs = KateApp::self()->documentManager()->documentList();
for (KTextEditor::Document *doc : docs) {
documentCreated(doc);
}
m_blockViewCreationAndActivation = false;
// Do it on next event loop iteration *after* the viewspace
// config has been read. This avoids
// - useless work (because current ViewSpace is destroyed when we restore config)
// - creates views for stashed docs correctly.
QTimer::singleShot(0, this, [this] {
// register all already existing documents
m_blockViewCreationAndActivation = true;
const auto &docs = KateApp::self()->documentManager()->documentList();
for (KTextEditor::Document *doc : docs) {
documentCreated(doc);
}
// init done
m_init = false;
m_blockViewCreationAndActivation = false;
});
}
KateViewManager::~KateViewManager()
......
......@@ -276,7 +276,6 @@ public Q_SLOTS:
private:
KateMainWindow *m_mainWindow;
bool m_init;
QAction *m_splitViewVert = nullptr;
QAction *m_splitViewHoriz = nullptr;
......
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