Skip to content

Commit 2aaf455

Browse files
committed
Create lock_file on stack
1 parent a9c0203 commit 2aaf455

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

mainwindow.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ void MainWindow::setup()
118118
ui->tabWidget->setTabVisible(Tab::Flatpak, arch != "i386");
119119
ui->tabWidget->setTabVisible(Tab::Test, QFile::exists("/etc/apt/sources.list.d/mx.list"));
120120

121-
lock_file = new LockFile("/var/lib/dpkg/lock");
122-
123121
test_initially_enabled
124122
= cmd.run("apt-get update --print-uris | grep -m1 -qE '/mx/testrepo/dists/" + ver_name + "/test/'");
125123

@@ -181,15 +179,15 @@ bool MainWindow::uninstall(const QString &names, const QString &preuninstall, co
181179
qDebug() << "Pre-uninstall";
182180
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Running pre-uninstall operations..."));
183181
enableOutput();
184-
if (lock_file->isLockedGUI()) {
182+
if (lock_file.isLockedGUI()) {
185183
return false;
186184
}
187185
success = cmd.runAsRoot(preuninstall);
188186
}
189187

190188
if (success) {
191189
enableOutput();
192-
if (lock_file->isLockedGUI()) {
190+
if (lock_file.isLockedGUI()) {
193191
return false;
194192
}
195193
success = cmd.runAsRoot("DEBIAN_FRONTEND=$(dpkg -l debconf-kde-helper 2>/dev/null | grep -sq ^i "
@@ -201,7 +199,7 @@ bool MainWindow::uninstall(const QString &names, const QString &preuninstall, co
201199
qDebug() << "Post-uninstall";
202200
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Running post-uninstall operations..."));
203201
enableOutput();
204-
if (lock_file->isLockedGUI()) {
202+
if (lock_file.isLockedGUI()) {
205203
return false;
206204
}
207205
success = cmd.runAsRoot(postuninstall);
@@ -212,7 +210,7 @@ bool MainWindow::uninstall(const QString &names, const QString &preuninstall, co
212210
bool MainWindow::updateApt()
213211
{
214212
qDebug() << "+++" << __PRETTY_FUNCTION__ << "+++";
215-
if (lock_file->isLockedGUI()) {
213+
if (lock_file.isLockedGUI()) {
216214
return false;
217215
}
218216
ui->tabOutput->isVisible() // Don't display in output if calling to refresh from tabs
@@ -1160,7 +1158,7 @@ bool MainWindow::install(const QString &names)
11601158
"DEBIAN_FRONTEND=$(dpkg -l debconf-kde-helper 2>/dev/null | grep -sq ^i && echo kde || echo gnome) "};
11611159
QString aptget {"apt-get -o=Dpkg::Use-Pty=0 install -y "};
11621160

1163-
if (lock_file->isLockedGUI()) {
1161+
if (lock_file.isLockedGUI()) {
11641162
return false;
11651163
}
11661164
QString recommends;
@@ -1204,7 +1202,7 @@ bool MainWindow::installBatch(const QStringList &name_list)
12041202
if (postinstall != '\n') {
12051203
qDebug() << "Post-install";
12061204
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Post-processing..."));
1207-
if (lock_file->isLockedGUI()) {
1205+
if (lock_file.isLockedGUI()) {
12081206
return false;
12091207
}
12101208
enableOutput();
@@ -1236,7 +1234,7 @@ bool MainWindow::installPopularApp(const QString &name)
12361234
if (!preinstall.isEmpty()) {
12371235
qDebug() << "Pre-install";
12381236
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Pre-processing for ") + name);
1239-
if (lock_file->isLockedGUI()) {
1237+
if (lock_file.isLockedGUI()) {
12401238
return false;
12411239
}
12421240
if (!cmd.runAsRoot(preinstall)) {
@@ -1258,7 +1256,7 @@ bool MainWindow::installPopularApp(const QString &name)
12581256
if (!postinstall.isEmpty()) {
12591257
qDebug() << "Post-install";
12601258
ui->tabWidget->setTabText(ui->tabWidget->indexOf(ui->tabOutput), tr("Post-processing for ") + name);
1261-
if (lock_file->isLockedGUI()) {
1259+
if (lock_file.isLockedGUI()) {
12621260
return false;
12631261
}
12641262
cmd.runAsRoot(postinstall);

mainwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private slots:
185185
bool warning_test {false};
186186

187187
Cmd cmd;
188-
LockFile *lock_file {};
188+
LockFile lock_file {"/var/lib/dpkg/lock"};
189189
QHash<QString, VersionNumber> listInstalledVersions();
190190
QIcon qicon_installed;
191191
QIcon qicon_upgradable;

0 commit comments

Comments
 (0)