Skip to content

Commit

Permalink
Try lock implementation with std::unique_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementKunz committed Oct 23, 2024
1 parent a4083be commit 9fde38a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ set(client_SRCS
synchronizeditem.h synchronizeditem.cpp
synchronizeditemwidget.h synchronizeditemwidget.cpp
synthesispopover.h synthesispopover.cpp
updater/updatedialog.h updater/updatedialog.cpp
updater/updatedialog.h updater/updatedialog.cpp
userselectionwidget.h userselectionwidget.cpp
customextensionsetupwidget.h customextensionsetupwidget.cpp
customlabel.h customlabel.cpp
Expand Down
9 changes: 4 additions & 5 deletions src/gui/clientgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,17 +758,16 @@ void ClientGui::onNewDriveWizard() {
raiseDialog(_addDriveWizard.get());
}

void ClientGui::onShowWindowsUpdateDialog(const VersionInfo &versionInfo) {
static LockUtility lock;
if (!lock.lock()) return;

void ClientGui::onShowWindowsUpdateDialog(const VersionInfo &versionInfo) const {
static std::mutex mutex;
if (const std::unique_lock lock(mutex, std::try_to_lock); !lock.owns_lock()) return;

if (UpdateDialog dialog(versionInfo); dialog.exec() == QDialog::Accepted) {
GuiRequests::startInstaller();
} else if (dialog.skip()) {
GuiRequests::skipUpdate(versionInfo.fullVersion());
}

lock.unlock();
}

void ClientGui::onDisableNotifications(NotificationsDisabled type, QDateTime value) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/clientgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ClientGui : public QObject, public std::enable_shared_from_this<ClientGui>
void onErrorsCleared(int syncDbId);
void onFixConflictingFilesCompleted(int syncDbId, uint64_t nbErrors);
void onNewDriveWizard();
void onShowWindowsUpdateDialog(const VersionInfo &versionInfo);
void onShowWindowsUpdateDialog(const KDC::VersionInfo &versionInfo) const;

private:
QScopedPointer<Systray> _tray;
Expand Down

0 comments on commit 9fde38a

Please sign in to comment.