Remove optional "parent" argument.

GenericThread used to accept an optional "parent" argument, defaulting to nullptr.
This was odd, because the moveToThread() in GenericThread::initialize() would
become a no-op if the instance ever inits QObject(someNonNullParentQObject).
(The only clue would be a log message "QObject::moveToThread: Cannot move objects with a parent",
 and things would end up in the same thread that created the instance.)
As it turns out, all the subclasses of GenericThread do not init
GenericThread(parent), so things worked as expected.
This commit is contained in:
Howard Stearns 2015-09-09 11:04:17 -07:00
parent 5572840133
commit 3f5744712f
4 changed files with 5 additions and 13 deletions

View file

@ -16,15 +16,7 @@
#include <display-plugins/DisplayPlugin.h>
#include "InterfaceLogging.h"
// GenericThread accepts an optional "parent" argument, defaulting to nullptr.
// This is odd, because the moveToThread() in GenericThread::initialize() will
// become a no-op if the instance ever inits QObject(someNonNullParentQObject).
// (The only clue will be a log message "QObject::moveToThread: Cannot move objects with a parent",
// and things will end up in the same thread that created this instance. Hillarity ensues.)
// As it turns out, all the other subclasses of GenericThread (at this time) do not init
// GenericThread(parent), so things work as expected. Here we explicitly init GenericThread(nullptr)
// so that there is no confusion and no chance for a hillarious thread debugging session.
AvatarUpdate::AvatarUpdate() : GenericThread(nullptr), _lastAvatarUpdate(0) {
AvatarUpdate::AvatarUpdate() : GenericThread(), _lastAvatarUpdate(0) {
setObjectName("Avatar Update"); // GenericThread::initialize uses this to set the thread name.
Settings settings;
const int DEFAULT_TARGET_AVATAR_SIMRATE = 60;

View file

@ -24,7 +24,7 @@ class GenericQueueThread : public GenericThread {
public:
using Queue = QQueue<T>;
GenericQueueThread(QObject* parent = nullptr)
: GenericThread(parent) {}
: GenericThread() {}
virtual ~GenericQueueThread() {}

View file

@ -14,8 +14,8 @@
#include "GenericThread.h"
GenericThread::GenericThread(QObject* parent) :
QObject(parent),
GenericThread::GenericThread() :
QObject(),
_stopThread(false),
_isThreaded(false) // assume non-threaded, must call initialize()
{

View file

@ -23,7 +23,7 @@
class GenericThread : public QObject {
Q_OBJECT
public:
GenericThread(QObject* parent = nullptr);
GenericThread();
virtual ~GenericThread();
/// Call to start the thread.