~santoshbit2007/oxide/Personal_branch_pointer_lock

« back to all changes in this revision

Viewing changes to qt/quick/api/oxideqquickwebcontextdelegateworker.cc

  • Committer: Chris Coulson
  • Date: 2016-04-08 19:52:02 UTC
  • Revision ID: chris.coulson@canonical.com-20160408195202-3k31g02watsxmoq0
Make WebContext only take ownership of WebContextDelegateWorker if it's unowned when it's first attached, rather than unconditionally taking ownership. This ensures they get cleaned up at the end of test cases. Prior to this, they leak in single process tests, causing subsequent test failures

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// vim:expandtab:shiftwidth=2:tabstop=2:
2
 
// Copyright (C) 2013 Canonical Ltd.
 
2
// Copyright (C) 2013-2016 Canonical Ltd.
3
3
 
4
4
// This library is free software; you can redistribute it and/or
5
5
// modify it under the terms of the GNU Lesser General Public
216
216
 
217
217
using namespace oxide::qquick::webcontextdelegateworker;
218
218
 
219
 
OxideQQuickWebContextDelegateWorkerPrivate::OxideQQuickWebContextDelegateWorkerPrivate() :
220
 
    constructed_(false),
221
 
    attached_count_(0),
222
 
    in_destruction_(false),
223
 
    io_thread_controller_(new IOThreadControllerImpl(), &QObject::deleteLater) {}
 
219
OxideQQuickWebContextDelegateWorkerPrivate::OxideQQuickWebContextDelegateWorkerPrivate()
 
220
    : attached_count(0),
 
221
      owned_by_context(false),
 
222
      constructed_(false),
 
223
      in_destruction_(false),
 
224
      io_thread_controller_(new IOThreadControllerImpl(), &QObject::deleteLater) {}
224
225
 
225
226
OxideQQuickWebContextDelegateWorkerPrivate::~OxideQQuickWebContextDelegateWorkerPrivate() {}
226
227
 
255
256
  Q_ASSERT(!d->in_destruction_);
256
257
  d->in_destruction_ = true;
257
258
 
258
 
  OxideQQuickWebContext* context = qobject_cast<OxideQQuickWebContext *>(parent());
259
 
  if (context) {
260
 
    OxideQQuickWebContextPrivate::get(context)->delegateWorkerDestroyed(this);
 
259
  if (d->context) {
 
260
    OxideQQuickWebContextPrivate::get(d->context)->delegateWorkerDestroyed(this);
261
261
  }
262
262
 
263
 
  Q_ASSERT(d->attached_count_ == 0);
 
263
  Q_ASSERT(d->attached_count == 0);
 
264
  Q_ASSERT(!d->context);
264
265
 
265
266
  disconnect(d->io_thread_controller_.data(),
266
267
             SIGNAL(error(const QString&)),