Changeset View
Changeset View
Standalone View
Standalone View
runners/bookmarks/bookmarksrunner.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
55 | 55 | | |||
56 | BookmarksRunner::~BookmarksRunner() | 56 | BookmarksRunner::~BookmarksRunner() | ||
57 | { | 57 | { | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | 60 | | |||
61 | void BookmarksRunner::prep() | 61 | void BookmarksRunner::prep() | ||
62 | { | 62 | { | ||
63 | m_browser = m_browserFactory->find(findBrowserName(), this); | 63 | auto browser = m_browserFactory->find(findBrowserName(), this); | ||
64 | connect(this, SIGNAL(teardown()), dynamic_cast<QObject*>(m_browser), SLOT(teardown())); | 64 | if (m_browser != browser) { | ||
65 | m_browser = browser; | ||||
davidedmundson: do we not also need a disconnect on m_browser? | |||||
Browser is just an interface class, but the subclasses also derive from QObject and should auto-disconnect, AFAIK. bruns: Browser is just an interface class, but the subclasses also derive from QObject and should auto… | |||||
66 | connect(this, &Plasma::AbstractRunner::teardown, | ||||
broulik: Please provide `this` as context. | |||||
bruns: you mean `this->mbrowser->teardown()`? | |||||
No, four-argument connect: connect(this, &..., this, .... Though you just connect from this anyway, so I guess this isn't needed broulik: No, four-argument connect:
```
connect(this, &..., this, ....
```
Though you just connect from… | |||||
Hm, just found that auto-disconnect (see @davidedmundson s comment) only works if you provide a context. The context has to be m_browser here. bruns: Hm, just found that auto-disconnect (see @davidedmundson s comment) only works if you provide a… | |||||
Ah, yeah, right, and then you could connect direcftly: connect(this, &Plasma::AbstractRunner:teardown, m_browser, &Browser::teardown); broulik: Ah, yeah, right, and then you could connect direcftly:
```
connect(this, &Plasma… | |||||
yes, after readding the dynamic_cast<QObject*>, m_browser is a non-QObject interface class. bruns: yes, after readding the `dynamic_cast<QObject*>`, m_browser is a non-QObject interface class. | |||||
The only syntax which works is connect(this, &Plasma::AbstractRunner:teardown, dynamic_cast<QObject*>(m_browser), [this] () { m_browser->teardown(); }); The context object has to be a QObject* (or derived). The other approach would be to make Browser a QObject derived class. bruns: The only syntax which works is
```
connect(this, &Plasma::AbstractRunner:teardown… | |||||
67 | dynamic_cast<QObject*>(m_browser), [this] () { m_browser->teardown(); }); | ||||
68 | } | ||||
65 | m_browser->prepare(); | 69 | m_browser->prepare(); | ||
66 | } | 70 | } | ||
67 | 71 | | |||
68 | 72 | | |||
69 | 73 | | |||
70 | void BookmarksRunner::match(Plasma::RunnerContext &context) | 74 | void BookmarksRunner::match(Plasma::RunnerContext &context) | ||
71 | { | 75 | { | ||
72 | if(! m_browser) return; | 76 | if(! m_browser) return; | ||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |
do we not also need a disconnect on m_browser?