Commit 3c4b80ff authored by Christoph Cullmann's avatar Christoph Cullmann 🍨 Committed by Eric Armbruster
Browse files

avoid crash after manual close of welcome view

we don't need to hold any pointer to the view,
handle the update via a signal, that is less error prone
parent 3891f7e0
......@@ -1525,20 +1525,19 @@ void KateViewManager::showWelcomeView()
if (activeView())
if (!m_welcomeView) {
m_welcomeView = new WelcomeView(this);
connect(m_welcomeView, &WelcomeView::openClicked, this, &KateViewManager::slotDocumentOpen);
connect(m_welcomeView, &WelcomeView::recentItemClicked, this, [this](const QUrl &url) {
connect(m_welcomeView, &WelcomeView::forgetRecentItem, this, &KateViewManager::forgetRecentItem);
auto recentFilesAction = mainWindow()->recentFilesAction();
connect(recentFilesAction, &KRecentFilesAction::recentListCleared, this, &KateViewManager::refreshRecentsOnWelcomeView);
connect(m_welcomeView, &WelcomeView::forgetAllRecents, recentFilesAction, &KRecentFilesAction::clear);
auto welcomeVeiw = new WelcomeView(this);
connect(welcomeVeiw, &WelcomeView::openClicked, this, &KateViewManager::slotDocumentOpen);
connect(welcomeVeiw, &WelcomeView::recentItemClicked, this, [this](const QUrl &url) {
connect(welcomeVeiw, &WelcomeView::forgetRecentItem, this, &KateViewManager::forgetRecentItem);
auto recentFilesAction = mainWindow()->recentFilesAction();
connect(recentFilesAction, &KRecentFilesAction::recentListCleared, this, &KateViewManager::refreshRecentsOnWelcomeView);
connect(welcomeVeiw, &WelcomeView::forgetAllRecents, recentFilesAction, &KRecentFilesAction::clear);
connect(this, &KateViewManager::loadRecentFiles, welcomeVeiw, &WelcomeView::loadRecents);
......@@ -1546,7 +1545,9 @@ void KateViewManager::showWelcomeView()
void KateViewManager::refreshRecentsOnWelcomeView()
// ensure welcome view updates
Q_EMIT loadRecentFiles();
void KateViewManager::forgetRecentItem(QUrl const &url)
......@@ -36,7 +36,6 @@ class KConfigGroup;
class KConfigBase;
class KateMainWindow;
class KateViewSpace;
class WelcomeView;
class KATE_PRIVATE_EXPORT KateViewManager : public KateSplitter
......@@ -116,6 +115,8 @@ Q_SIGNALS:
void showUrlNavBarChanged(bool);
void loadRecentFiles();
* create and activate a new view for doc, if doc == 0, then
......@@ -388,8 +389,6 @@ private:
* last url of open file dialog, used if current document has no valid url
QUrl m_lastOpenDialogUrl;
WelcomeView *m_welcomeView = nullptr;
......@@ -27,8 +27,15 @@ public:
explicit WelcomeView(QWidget *parent = nullptr);
~WelcomeView() override;
public Q_SLOTS:
void loadRecents();
// ensure we can always close this view
bool shouldClose()
return true;
void openClicked();
void recentItemClicked(QUrl const &url);
Supports Markdown
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