Commit 3b2de5dd authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

improve session signals and sessions action test

parent 311dd0f5
Pipeline #170150 failed with stage
in 6 minutes and 1 second
......@@ -25,15 +25,13 @@ void KateSessionsActionTest::init()
static QCommandLineParser parser;
m_app = new KateApp(parser, KateApp::ApplicationKate, m_tempdir->path());
m_app->sessionManager()->activateAnonymousSession();
m_manager = new KateSessionManager(this, m_tempdir->path());
m_manager = m_app->sessionManager();
m_ac = new KateSessionsAction(QStringLiteral("menu"), this, m_manager, false);
}
void KateSessionsActionTest::cleanup()
{
delete m_ac;
delete m_manager;
delete m_app;
delete m_tempdir;
}
......@@ -49,10 +47,9 @@ void KateSessionsActionTest::basic()
void KateSessionsActionTest::limit()
{
for (int i = 0; i < 14; i++) {
m_manager->activateSession(QStringLiteral("session %1").arg(i));
m_manager->copySession(m_manager->activeSession(), QStringLiteral("session %1").arg(i));
}
QCOMPARE(m_manager->activeSession()->isAnonymous(), false);
QCOMPARE(m_manager->sessionList().size(), 14);
QCOMPARE(m_ac->isEnabled(), true);
......
......@@ -258,11 +258,10 @@ bool KateSessionManager::deleteSession(KateSession::Ptr session)
}
QFile::remove(session->file());
// ensure session list is updated
m_sessions.remove(session->name());
// Due to this remove from m_sessions will updateSessionList() no signal emit,
// but this way is there no delay between deletion and information
Q_EMIT sessionListChanged();
return true;
}
......@@ -279,6 +278,9 @@ QString KateSessionManager::copySession(const KateSession::Ptr &session, const Q
KateSession::Ptr ns = KateSession::createFrom(session, newFile, name);
ns->config()->sync();
// ensure session list is updated
m_sessions[ns->name()] = ns;
Q_EMIT sessionListChanged();
return name;
}
......@@ -301,11 +303,14 @@ QString KateSessionManager::renameSession(KateSession::Ptr session, const QStrin
return QString();
}
m_sessions[newName] = m_sessions.take(session->name());
// update session name and sync
const auto oldName = session->name();
session->setName(newName);
session->setFile(newFile);
session->config()->sync();
// updateSessionList() will this edit not notice, so force signal
// ensure session list is updated
m_sessions[session->name()] = m_sessions.take(oldName);
Q_EMIT sessionListChanged();
if (session == activeSession()) {
......
......@@ -29,7 +29,7 @@ KateSessionsAction::KateSessionsAction(const QString &text, QObject *parent, Kat
// the current code path is executed ---> crash. See bug #227008.
connect(sessionsGroup, &QActionGroup::triggered, this, &KateSessionsAction::openSession, Qt::QueuedConnection);
connect(m_manager, &KateSessionManager::sessionChanged, this, &KateSessionsAction::slotSessionChanged);
connect(m_manager, &KateSessionManager::sessionListChanged, this, &KateSessionsAction::slotSessionChanged);
setDisabled(m_manager->sessionList().empty());
}
......
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