Clean up QPlatformPrinterSupport via post routine.
Change-Id: I5aff587f0186f15c9fa65d236e5ebe9a7901dd86 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
fe220f3b5b
commit
e00a961732
@ -40,7 +40,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qplatformprintplugin.h"
|
#include "qplatformprintplugin.h"
|
||||||
|
#include "qplatformprintersupport.h"
|
||||||
|
#include "qprinterinfo.h"
|
||||||
#include "private/qfactoryloader_p.h"
|
#include "private/qfactoryloader_p.h"
|
||||||
|
#include <qcoreapplication.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -58,6 +61,14 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QPlatformPrinterSupport *printerSupport = 0;
|
||||||
|
|
||||||
|
static void cleanupPrinterSupport()
|
||||||
|
{
|
||||||
|
delete printerSupport;
|
||||||
|
printerSupport = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
|
|
||||||
@ -68,13 +79,14 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
|
|||||||
*/
|
*/
|
||||||
QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
|
QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
|
||||||
{
|
{
|
||||||
static QPlatformPrinterSupport *singleton = 0;
|
if (!printerSupport) {
|
||||||
if (!singleton) {
|
|
||||||
const QMultiMap<int, QString> keyMap = loader()->keyMap();
|
const QMultiMap<int, QString> keyMap = loader()->keyMap();
|
||||||
if (!keyMap.isEmpty())
|
if (!keyMap.isEmpty())
|
||||||
singleton = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), keyMap.constBegin().value());
|
printerSupport = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), keyMap.constBegin().value());
|
||||||
|
if (printerSupport)
|
||||||
|
qAddPostRoutine(cleanupPrinterSupport);
|
||||||
}
|
}
|
||||||
return singleton;
|
return printerSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user