diff options
author | Erik Verbruggen <erik@verbruggen.consulting> | 2021-10-15 15:05:01 +0300 |
---|---|---|
committer | Erik Verbruggen <Erik.Verbruggen@Me.com> | 2021-12-03 12:45:08 +0300 |
commit | 470bf76e6362a4379e6548e466971e3a2e532ccd (patch) | |
tree | f697e03da9fde7e1d97394d867c6c3eed7f314d9 /src/gui/sharedialog.h | |
parent | ed603153da4fdc385f90982c88660fe0cec2f7ea (diff) |
Use the refcounted AccountStatePtr as much as possible
The AccountManager creates AccountState objects, and stores them in a
shared pointer.
Previously, the raw pointer was given out, and stored in other objects.
That made removal very tricky: when an account gets removed, the
underlying object gets deleted, and then all classes that listen get
notified of the deletion. Those classes would sometimes put a nullptr
into the AccountState pointer they stored, and in each usage would
(hopefully) check for a nullptr. The problem was that a number of checks
were missing, which the clang static analyser pointed out.
This patch changes nearly all uses of a raw pointer into the shared
pointer, thereby making sure all usages have a valid reference, even
when account deletion happens. The two places where a raw pointer is
still used, now put it into a refcounted pointer as soon as possible.
Diffstat (limited to 'src/gui/sharedialog.h')
-rw-r--r-- | src/gui/sharedialog.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index a8f7a1759..46dfbf661 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -40,7 +40,7 @@ class ShareDialog : public QDialog Q_OBJECT public: - explicit ShareDialog(QPointer<AccountState> accountState, + explicit ShareDialog(AccountStatePtr accountState, const QString &sharePath, const QString &localPath, SharePermissions maxSharingPermissions, @@ -60,7 +60,7 @@ private: void showSharingUi(); Ui::ShareDialog *_ui; - QPointer<AccountState> _accountState; + AccountStatePtr _accountState; QString _sharePath; QString _localPath; SharePermissions _maxSharingPermissions; |