File tree Expand file tree Collapse file tree 4 files changed +6
-14
lines changed Expand file tree Collapse file tree 4 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,16 @@ PolkitAgentImpl* PolkitAgentImpl::tryGet(const PolkitAgent* agent) {
6060 return nullptr ;
6161}
6262
63- PolkitAgentImpl* PolkitAgentImpl::tryTakeover (PolkitAgent* agent) {
64- if (instance = = nullptr ) return nullptr ;
63+ PolkitAgentImpl* PolkitAgentImpl::tryTakeoverOrCreate (PolkitAgent* agent) {
64+ if (auto * impl = tryGetOrCreate (agent); impl ! = nullptr ) return impl ;
6565
6666 auto * prevGen = EngineGeneration::findObjectGeneration (instance->qmlAgent );
6767 auto * myGen = EngineGeneration::findObjectGeneration (agent);
6868 if (prevGen == myGen) return nullptr ;
6969
7070 qCDebug (logPolkit) << " taking over listener from previous generation" ;
7171 instance->qmlAgent = agent;
72+ instance->setPath (agent->path ());
7273
7374 return instance;
7475}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class PolkitAgentImpl
2323
2424 static PolkitAgentImpl* tryGetOrCreate (PolkitAgent* agent);
2525 static PolkitAgentImpl* tryGet (const PolkitAgent* agent);
26- static PolkitAgentImpl* tryTakeover (PolkitAgent* agent);
26+ static PolkitAgentImpl* tryTakeoverOrCreate (PolkitAgent* agent);
2727 static void onEndOfQmlAgent (PolkitAgent* agent);
2828
2929 [[nodiscard]] QBindable<AuthFlow*> activeFlow ();
Original file line number Diff line number Diff line change @@ -11,22 +11,14 @@ QS_LOGGING_CATEGORY(logPolkit, "quickshell.service.polkit");
1111}
1212
1313namespace qs ::service::polkit {
14- PolkitAgent::PolkitAgent (QObject* parent): QObject(parent) {
15- // Try to takeover an existing PolkitAgentImpl from the previous QML engine generation.
16- // If none exists, we wait until componentComplete to create one so we have the correct path.
17- PolkitAgentImpl::tryTakeover (this );
18- }
19-
2014PolkitAgent::~PolkitAgent () { PolkitAgentImpl::onEndOfQmlAgent (this ); };
2115
2216void PolkitAgent::componentComplete () {
2317 if (this ->mPath .isEmpty ()) this ->mPath = " /org/quickshell/Polkit" ;
2418
25- auto * impl = PolkitAgentImpl::tryGetOrCreate (this );
19+ auto * impl = PolkitAgentImpl::tryTakeoverOrCreate (this );
2620 if (impl == nullptr ) return ;
2721
28- impl->setPath (this ->mPath );
29-
3022 this ->bFlow .setBinding ([impl]() { return impl->activeFlow ().value (); });
3123 this ->bIsActive .setBinding ([impl]() { return impl->activeFlow ().value () != nullptr ; });
3224 this ->bIsRegistered .setBinding ([impl]() { return impl->isRegistered ().value (); });
Original file line number Diff line number Diff line change 1212#include " ../../core/model.hpp"
1313#include " ../../core/reload.hpp"
1414#include " ../../core/retainable.hpp"
15-
1615#include " flow.hpp"
1716
1817// The reserved identifier is exactly the struct I mean.
@@ -56,7 +55,7 @@ class PolkitAgent
5655 Q_PROPERTY (AuthFlow* flow READ default NOTIFY flowChanged BINDABLE flow);
5756
5857public:
59- explicit PolkitAgent (QObject* parent = nullptr );
58+ explicit PolkitAgent (QObject* parent = nullptr ): QObject(parent) {} ;
6059 ~PolkitAgent () override ;
6160
6261 void classBegin () override {};
You can’t perform that action at this time.
0 commit comments