summaryrefslogtreecommitdiffstats
path: root/src/printsupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport')
-rw-r--r--src/printsupport/dialogs/qprintdialog_win.cpp4
-rw-r--r--src/printsupport/kernel/qprinter.cpp8
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp29
-rw-r--r--src/printsupport/kernel/qprinterinfo_p.h13
4 files changed, 24 insertions, 30 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_win.cpp b/src/printsupport/dialogs/qprintdialog_win.cpp
index 96a201ae45..6f96a499e5 100644
--- a/src/printsupport/dialogs/qprintdialog_win.cpp
+++ b/src/printsupport/dialogs/qprintdialog_win.cpp
@@ -187,7 +187,7 @@ QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
Q_D(QPrintDialog);
if (!warnIfNotNative(d->printer))
return;
- d->ep = static_cast<QWin32PrintEngine *>(d->printer->paintEngine())->d_func();
+ d->ep = static_cast<QWin32PrintEngine *>(d->printer->printEngine())->d_func();
setAttribute(Qt::WA_DontShowOnScreen);
}
@@ -197,7 +197,7 @@ QPrintDialog::QPrintDialog(QWidget *parent)
Q_D(QPrintDialog);
if (!warnIfNotNative(d->printer))
return;
- d->ep = static_cast<QWin32PrintEngine *>(d->printer->paintEngine())->d_func();
+ d->ep = static_cast<QWin32PrintEngine *>(d->printer->printEngine())->d_func();
setAttribute(Qt::WA_DontShowOnScreen);
}
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 0905cbb59f..819f9343f7 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -55,10 +55,7 @@
#include <private/qpagedpaintdevice_p.h>
-
-#ifndef QT_NO_PDF
#include "qprintengine_pdf_p.h"
-#endif
#include <qpicture.h>
#include <private/qpaintengine_preview_p.h>
@@ -618,8 +615,6 @@ QPrinter::~QPrinter()
*/
void QPrinter::setOutputFormat(OutputFormat format)
{
-
-#ifndef QT_NO_PDF
Q_D(QPrinter);
if (d->validPrinter && d->outputFormat == format)
return;
@@ -651,9 +646,6 @@ void QPrinter::setOutputFormat(OutputFormat format)
if (d->outputFormat == QPrinter::PdfFormat)
d->validPrinter = true;
-#else
- Q_UNUSED(format);
-#endif
}
/*!
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index f863b23e34..e02617fe93 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -35,8 +35,17 @@
QT_BEGIN_NAMESPACE
-QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
+Q_GLOBAL_STATIC(QPrinterInfoPrivate, shared_null);
+class QPrinterInfoPrivateDeleter
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != shared_null)
+ delete d;
+ }
+};
/*!
\class QPrinterInfo
@@ -83,7 +92,7 @@ QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
\sa isNull()
*/
QPrinterInfo::QPrinterInfo()
- : d_ptr(&QPrinterInfoPrivate::shared_null)
+ : d_ptr(shared_null)
{
}
@@ -91,7 +100,7 @@ QPrinterInfo::QPrinterInfo()
Constructs a copy of \a other.
*/
QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
- : d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
+ : d_ptr((other.d_ptr.data() == shared_null) ? shared_null : new QPrinterInfoPrivate(*other.d_ptr))
{
}
@@ -99,12 +108,15 @@ QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
Constructs a QPrinterInfo object from \a printer.
*/
QPrinterInfo::QPrinterInfo(const QPrinter &printer)
- : d_ptr(&QPrinterInfoPrivate::shared_null)
+ : d_ptr(shared_null)
{
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps) {
QPrinterInfo pi = ps->printerInfo(printer.printerName());
- d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr));
+ if (pi.d_ptr.data() == shared_null)
+ d_ptr.reset(shared_null);
+ else
+ d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr));
}
}
@@ -130,7 +142,10 @@ QPrinterInfo::~QPrinterInfo()
QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
{
Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
+ if (other.d_ptr.data() == shared_null)
+ d_ptr.reset(shared_null);
+ else
+ d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
return *this;
}
@@ -191,7 +206,7 @@ QString QPrinterInfo::makeAndModel() const
bool QPrinterInfo::isNull() const
{
Q_D(const QPrinterInfo);
- return d == &QPrinterInfoPrivate::shared_null;
+ return d == shared_null || d->name.isEmpty();
}
/*!
diff --git a/src/printsupport/kernel/qprinterinfo_p.h b/src/printsupport/kernel/qprinterinfo_p.h
index d4bb08f1f5..6ae64b5653 100644
--- a/src/printsupport/kernel/qprinterinfo_p.h
+++ b/src/printsupport/kernel/qprinterinfo_p.h
@@ -72,8 +72,6 @@ public:
~QPrinterInfoPrivate()
{}
- static QPrinterInfoPrivate shared_null;
-
QString name;
QString description;
QString location;
@@ -87,17 +85,6 @@ public:
mutable QList<QPair<QString, QSizeF> > paperNames;
};
-
-class QPrinterInfoPrivateDeleter
-{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &QPrinterInfoPrivate::shared_null)
- delete d;
- }
-};
-
QT_END_NAMESPACE
#endif // QT_NO_PRINTER