Fix resource leaks (coverity)

This commit is contained in:
Kurt Hindenburg
2025-12-01 08:15:28 -05:00
committed by Kurt Hindenburg
parent 045b214c6a
commit e3ab6bd36f
3 changed files with 9 additions and 8 deletions

View File

@@ -38,7 +38,7 @@ void ProfileTest::initTestCase()
void ProfileTest::testProfile()
{
// create a new profile
Profile *parent = new Profile;
Profile::Ptr parent(new Profile);
parent->setProperty(Profile::Name, QStringLiteral("Parent"));
parent->setProperty(Profile::Path, QStringLiteral("FakePath"));
@@ -55,7 +55,7 @@ void ProfileTest::testProfile()
QCOMPARE(parent->customCursorTextColor(), QColor());
// create a child profile
Profile *child = new Profile(Profile::Ptr(parent));
Profile::Ptr child(new Profile(parent));
child->setProperty(Profile::StartInCurrentSessionDir, true);
// check which properties are set
@@ -83,8 +83,6 @@ void ProfileTest::testProfile()
QVERIFY(!parent->startInCurrentSessionDir());
QVERIFY(child->startInCurrentSessionDir());
delete child;
}
void ProfileTest::testClone()

View File

@@ -206,13 +206,16 @@ const KeyboardTranslator *KeyboardTranslatorManager::defaultTranslator()
return translator;
}
auto fallback = new KeyboardTranslator(QStringLiteral("fallback"));
// Create a fallback translator and register it in _translators
auto *fallback = new KeyboardTranslator(QStringLiteral("fallback"));
fallback->setDescription(QStringLiteral("Fallback Keyboard Translator"));
// Key "TAB" should send out '\t'
KeyboardTranslator::Entry entry;
entry.setKeyCode(Qt::Key_Tab);
entry.setText("\t");
fallback->addEntry(entry);
_translators.insert(fallback->name(), fallback);
return fallback;
}

View File

@@ -1871,17 +1871,17 @@ bool Session::copyInputToAllSessions()
bool Session::copyInputToSessions(QList<int> sessionIds)
{
if (auto c = controller()) {
auto sessions = new QList<Session *>();
QList<Session *> sessions;
c->copyInputActions()->setCurrentItem(SessionController::CopyInputToSelectedTabsMode);
for (auto sessionId : sessionIds) {
if (auto session = SessionManager::instance()->idToSession(sessionId))
sessions->append(session);
sessions.append(session);
else
return false;
}
c->copyInputToSelectedTabs(sessions);
c->copyInputToSelectedTabs(&sessions);
return true;
}