@@ -39,18 +39,10 @@
3939
4040Scope::Scope(QObject *parent) : QObject(parent)
4141 , m_formFactor("phone")
42− , m_previewCancellable(nullptr)
4342{
4443 m_categories.reset(new Categories(this));
4544}
4645
47−Scope::~Scope()
48−{
49− if (m_previewCancellable) {
50− g_object_unref(m_previewCancellable);
51− }
52−}
53−
5446QString Scope::id() const
5547{
5648 return QString::fromStdString(m_unityScope->id());
@@ -183,14 +175,14 @@ void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVaria
183175 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
184176{
185177 auto res = createLocalResult(uri, icon_hint, category, result_type, mimetype, title, comment, dnd_uri, metadata);
186−
187− if (m_previewCancellable) {
188− g_cancellable_cancel(m_previewCancellable);
189− g_object_unref(m_previewCancellable);
190− }
191− m_previewCancellable = g_cancellable_new();
178+ m_previewCancellable.Renew();
192179 m_unityScope->Preview(res, nullptr, m_previewCancellable);
193180}
181+
182+void Scope::cancelActivation()
183+{
184+ m_previewCancellable.Cancel();
185+}
194186
195187void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
196188{
@@ -220,10 +212,6 @@ void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::Sco
220212
221213void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::dash::Preview::Ptr const& preview)
222214{
223− if (m_previewCancellable) {
224− g_object_unref(m_previewCancellable);
225− m_previewCancellable = nullptr;
226− }
227215 auto prv = Preview::newFromUnityPreview(preview);
228216 // is this the best solution? QML may need to keep more than one preview instance around, so we can't own it.
229217 // passing it by value is not possible.