fix(crashes): stop destroying QThread workers while still running
Deleting SearchWorker/ListWorker/InstallWorker from the `finished` -> `deleteLater` connection aborted the app with "QThread: Destroyed while thread is still running" (SIGABRT) whenever a list loaded or a package op finished. The deferred delete raced the thread teardown because these workers have no event loop to process it after run() returns. Wait for the thread to complete (wait() clears the running flag, and by then run() already emitted finished) before scheduling deleteLater, and bind every cross-thread signal to the MainWindow context object so the handlers run queued on the GUI thread instead of inside the worker. Also drop the intrusive popups (removal confirmation, pacman/sudo unavailable, empty-search notice) in favour of status bar messages, and let sudo take the password via -S so no per-op polkit dialog is shown. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
5 files changed
+264
-67
No files matched your search
@@ -9,6 +9,7 @@
|
||||
#include <QProgressBar>
|
||||
#include <QComboBox>
|
||||
#include <QThread>
|
||||
#include <QSettings>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -24,6 +25,7 @@ class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QButtonGroup;
|
||||
class QFrame;
|
||||
class QAction;
|
||||
|
||||
// Runs a package search off the UI thread.
|
||||
class SearchWorker : public QThread {
|
||||
@@ -94,6 +96,14 @@ private slots:
|
||||
private:
|
||||
enum BrowseMode { ModeSearch, ModeInstalled, ModeUpdates };
|
||||
|
||||
// When the sudo password is requested: once per session (at launch) or
|
||||
// before every privileged operation.
|
||||
enum class CredentialMode { AtLaunch, EachTime };
|
||||
|
||||
void applyCredentialMode(CredentialMode mode);
|
||||
bool ensureCredentials();
|
||||
void clearCredentialsAfterUse();
|
||||
|
||||
void setupUI();
|
||||
void setupSidebar();
|
||||
void setupHeader();
|
||||
@@ -174,6 +184,12 @@ private:
|
||||
HistoryManager* m_historyManager = nullptr;
|
||||
BrowseMode m_browseMode = ModeSearch;
|
||||
|
||||
// Settings
|
||||
QSettings m_settings;
|
||||
CredentialMode m_credentialMode = CredentialMode::EachTime;
|
||||
QAction* m_credLaunchAction = nullptr;
|
||||
QAction* m_credEachTimeAction = nullptr;
|
||||
|
||||
std::vector<PackageInfo> m_currentResults;
|
||||
std::vector<PackageInfo> m_installedPackages;
|
||||
PackageInfo m_selectedPackage;
|
||||
|
||||
Reference in new issue
Block a user