[mythtv] "base class should be explicitly initialized" errors

Jean-Yves Avenard jyavenard at gmail.com
Tue Jun 6 08:45:42 UTC 2017


Hi

On 3 June 2017 at 02:06, David Hampton <mythtv at dhampton.net> wrote:
> Hi all. I'm still slogging my way through all the warnings created by
> adding the -Wextra flag to compiles, and decided it was finally time to
> tackle this class of warning:
>
>   In copy constructor ‘blah::blah(const blah&)’:
>   warning: base class ‘class QObject’ should be explicitly
>   initialized in the copy constructor [-Wextra]
>   blah::blah(const blah &other)

Yes, the base constructor must be called here.. I'm surprised it could
ever compile without it.

>
> This warning occurs on objects defined in these files:
>
>   libs/libmythbase/filesysteminfo.h
>   libs/libmythbase/mythdownloadmanager.cpp
>   libs/libmythbase/mythsystemlegacy.h
>   libs/libmythmetadata/metadatagrabber.h
>   libs/libmythservicecontracts/enums/recStatus.h
>   Everything under libs/libmythservicecontracts/datacontracts
>
> The trivial solution would seem to be initializing the base qobject in
> the copy constructor, only that results in a different bunch of
> warnings like this:
>
>   In copy constructor ‘blah::blah(const blah&)’:
>   error: ‘QObject::QObject(const QObject&)’ is private within
>   this context : QObject(other)
>   /usr/include/qt5/QtCore/qobject.h: note: declared private here
>      Q_DISABLE_COPY(QObject)
>
> That got me researching the topic, which led me to these references..
>
>     http://doc.qt.io/qt-5/qobject.html#Q_DISABLE_COPY
>     https://www.ics.com/designpatterns/book/qobject.html
>
> ..which basically say you should never copy things derived from a
> qobject. They represent unique entities, not things that can be run
> through a xerox machine.

well you can, but not a plain QObject. But things like QString and so
on, handle Copy on Write


More information about the mythtv-dev mailing list