Skip to content

Commit

Permalink
Create lock_file on stack
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianTM committed Jul 14, 2024
1 parent a9c0203 commit 2aaf455
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ void MainWindow::setup()
ui->tabWidget->setTabVisible(Tab::Flatpak, arch != "i386");
ui->tabWidget->setTabVisible(Tab::Test, QFile::exists("/etc/apt/sources.list.d/mx.list"));

lock_file = new LockFile("/var/lib/dpkg/lock");

test_initially_enabled
= cmd.run("apt-get update --print-uris | grep -m1 -qE '/mx/testrepo/dists/" + ver_name + "/test/'");

Expand Down Expand Up @@ -181,15 +179,15 @@ bool MainWindow::uninstall(const QString &names, const QString &preuninstall, co
qDebug() << "Pre-uninstall";
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Running pre-uninstall operations..."));
enableOutput();
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
success = cmd.runAsRoot(preuninstall);
}

if (success) {
enableOutput();
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
success = cmd.runAsRoot("DEBIAN_FRONTEND=$(dpkg -l debconf-kde-helper 2>/dev/null | grep -sq ^i "
Expand All @@ -201,7 +199,7 @@ bool MainWindow::uninstall(const QString &names, const QString &preuninstall, co
qDebug() << "Post-uninstall";
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Running post-uninstall operations..."));
enableOutput();
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
success = cmd.runAsRoot(postuninstall);
Expand All @@ -212,7 +210,7 @@ bool MainWindow::uninstall(const QString &names, const QString &preuninstall, co
bool MainWindow::updateApt()
{
qDebug() << "+++" << __PRETTY_FUNCTION__ << "+++";
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
ui->tabOutput->isVisible() // Don't display in output if calling to refresh from tabs
Expand Down Expand Up @@ -1160,7 +1158,7 @@ bool MainWindow::install(const QString &names)
"DEBIAN_FRONTEND=$(dpkg -l debconf-kde-helper 2>/dev/null | grep -sq ^i && echo kde || echo gnome) "};
QString aptget {"apt-get -o=Dpkg::Use-Pty=0 install -y "};

if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
QString recommends;
Expand Down Expand Up @@ -1204,7 +1202,7 @@ bool MainWindow::installBatch(const QStringList &name_list)
if (postinstall != '\n') {
qDebug() << "Post-install";
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Post-processing..."));
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
enableOutput();
Expand Down Expand Up @@ -1236,7 +1234,7 @@ bool MainWindow::installPopularApp(const QString &name)
if (!preinstall.isEmpty()) {
qDebug() << "Pre-install";
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Pre-processing for ") + name);
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
if (!cmd.runAsRoot(preinstall)) {
Expand All @@ -1258,7 +1256,7 @@ bool MainWindow::installPopularApp(const QString &name)
if (!postinstall.isEmpty()) {
qDebug() << "Post-install";
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Post-processing for ") + name);
if (lock_file->isLockedGUI()) {
if (lock_file.isLockedGUI()) {
return false;
}
cmd.runAsRoot(postinstall);
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private slots:
bool warning_test {false};

Cmd cmd;
LockFile *lock_file {};
LockFile lock_file {"/var/lib/dpkg/lock"};
QHash<QString, VersionNumber> listInstalledVersions();
QIcon qicon_installed;
QIcon qicon_upgradable;
Expand Down

0 comments on commit 2aaf455

Please sign in to comment.