Remove hack that violates ODR

GCC with LTO sees through our hack:

qprintdialog_unix.cpp:212:7: warning: type ‘struct QPrintDialogPrivate’ violates the C++ One Definition Rule [-Wodr]
qabstractprintdialog.cpp:49:7: note: a different type is defined in another translation unit

This hack was there so that the QPrintDialog functions in
qabstractprintdialog.cpp could use the d pointer. So instead of hacking
around the issue, just use the class that this file has access to:
QAbstractPrintDialogPrivate.

Change-Id: I3840d727dee443318644fffd1528e2e8b814e983
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Thiago Macieira 2018-04-25 21:46:02 -07:00
parent 26e3dfd4ab
commit 2660aefdbc

View File

@ -45,11 +45,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
// hack
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
{
};
/*! /*!
\class QAbstractPrintDialog \class QAbstractPrintDialog
\brief The QAbstractPrintDialog class provides a base implementation for \brief The QAbstractPrintDialog class provides a base implementation for
@ -145,7 +140,7 @@ QAbstractPrintDialog::~QAbstractPrintDialog()
*/ */
void QPrintDialog::setOption(PrintDialogOption option, bool on) void QPrintDialog::setOption(PrintDialogOption option, bool on)
{ {
Q_D(QPrintDialog); auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
if (!(d->options & option) != !on) if (!(d->options & option) != !on)
setOptions(d->options ^ option); setOptions(d->options ^ option);
} }
@ -158,7 +153,7 @@ void QPrintDialog::setOption(PrintDialogOption option, bool on)
*/ */
bool QPrintDialog::testOption(PrintDialogOption option) const bool QPrintDialog::testOption(PrintDialogOption option) const
{ {
Q_D(const QPrintDialog); auto *d = static_cast<const QAbstractPrintDialogPrivate *>(d_ptr.data());
return (d->options & option) != 0; return (d->options & option) != 0;
} }
@ -177,7 +172,7 @@ bool QPrintDialog::testOption(PrintDialogOption option) const
*/ */
void QPrintDialog::setOptions(PrintDialogOptions options) void QPrintDialog::setOptions(PrintDialogOptions options)
{ {
Q_D(QPrintDialog); auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
PrintDialogOptions changed = (options ^ d->options); PrintDialogOptions changed = (options ^ d->options);
if (!changed) if (!changed)
@ -188,7 +183,7 @@ void QPrintDialog::setOptions(PrintDialogOptions options)
QPrintDialog::PrintDialogOptions QPrintDialog::options() const QPrintDialog::PrintDialogOptions QPrintDialog::options() const
{ {
Q_D(const QPrintDialog); auto *d = static_cast<const QAbstractPrintDialogPrivate *>(d_ptr.data());
return d->options; return d->options;
} }
@ -464,7 +459,7 @@ void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs)
*/ */
void QPrintDialog::done(int result) void QPrintDialog::done(int result)
{ {
Q_D(QPrintDialog); auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
QDialog::done(result); QDialog::done(result);
if (result == Accepted) if (result == Accepted)
emit accepted(printer()); emit accepted(printer());
@ -487,7 +482,7 @@ void QPrintDialog::done(int result)
*/ */
void QPrintDialog::open(QObject *receiver, const char *member) void QPrintDialog::open(QObject *receiver, const char *member)
{ {
Q_D(QPrintDialog); auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
connect(this, SIGNAL(accepted(QPrinter*)), receiver, member); connect(this, SIGNAL(accepted(QPrinter*)), receiver, member);
d->receiverToDisconnectOnClose = receiver; d->receiverToDisconnectOnClose = receiver;
d->memberToDisconnectOnClose = member; d->memberToDisconnectOnClose = member;