Make qtbase compile with QT_NO_TEMPORARYFILE

Change-Id: Ida2f59bb245ef70bf65f7e8944c4c315d5bc2f81
Reviewed-by: David Faure (KDE) <faure@kde.org>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Tasuku Suzuki 2013-04-13 15:54:12 +09:00 committed by The Qt Project
parent 092a2f813c
commit 830cbb1aaf
13 changed files with 79 additions and 8 deletions

View File

@ -311,6 +311,11 @@
#define QT_NO_LOCALSERVER
#endif
// QPdf
#if !defined(QT_NO_PDF) && (defined(QT_NO_TEMPORARYFILE))
#define QT_NO_PDF
#endif
// QMenu
#if !defined(QT_NO_MENU) && (defined(QT_NO_ACTION))
#define QT_NO_MENU

View File

@ -851,6 +851,13 @@ Requires:
Name: Color Names
SeeAlso: ???
Feature: PDF
Description: Supports pdf format
Section: Painting
Requires: TEMPORARYFILE
Name: QPdf
SeeAlso: ???
Feature: PRINTER
Description: Supports printing
Section: Painting

View File

@ -45,6 +45,7 @@
#include "QtCore/qcoreapplication.h"
#include "QtCore/qfileinfo.h"
#include "QtCore/qdebug.h"
#include "QtCore/qdatetime.h"
#include "private/qcore_unix_p.h" // qt_safe_open
#include "private/qabstractfileengine_p.h"
@ -80,12 +81,13 @@ static qint64 qt_write_loop(int fd, const char *data, qint64 len)
int QLockFilePrivate::checkFcntlWorksAfterFlock()
{
#ifndef QT_NO_TEMPORARYFILE
QTemporaryFile file;
if (!file.open())
return -2;
return 0;
const int fd = file.d_func()->engine()->handle();
if (flock(fd, LOCK_EX | LOCK_NB) == -1) // other threads, and other processes on a local fs
return -3;
return 0;
struct flock flockData;
flockData.l_type = F_WRLCK;
flockData.l_whence = SEEK_SET;
@ -95,6 +97,9 @@ int QLockFilePrivate::checkFcntlWorksAfterFlock()
if (fcntl(fd, F_SETLK, &flockData) == -1) // for networked filesystems
return 0;
return 1;
#else
return 0;
#endif
}
static QBasicAtomicInt fcntlOK = Q_BASIC_ATOMIC_INITIALIZER(-1);

View File

@ -39,8 +39,11 @@
**
****************************************************************************/
#include "qplatformdefs.h"
#include "qsavefile.h"
#ifndef QT_NO_TEMPORARYFILE
#include "qplatformdefs.h"
#include "private/qsavefile_p.h"
#include "qfileinfo.h"
#include "qabstractfileengine_p.h"
@ -381,3 +384,5 @@ bool QSaveFile::directWriteFallback() const
}
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE

View File

@ -42,6 +42,10 @@
#ifndef QSAVEFILE_H
#define QSAVEFILE_H
#include <QtCore/qglobal.h>
#ifndef QT_NO_TEMPORARYFILE
#include <QtCore/qfiledevice.h>
#include <QtCore/qstring.h>
@ -51,7 +55,6 @@
QT_BEGIN_NAMESPACE
class QAbstractFileEngine;
class QSaveFilePrivate;
@ -90,4 +93,6 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE
#endif // QSAVEFILE_H

View File

@ -53,6 +53,10 @@
// We mean it.
//
#include <QtCore/qglobal.h>
#ifndef QT_NO_TEMPORARYFILE
#include "private/qfiledevice_p.h"
QT_BEGIN_NAMESPACE
@ -75,4 +79,6 @@ protected:
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE
#endif // QSAVEFILE_P_H

View File

@ -42,6 +42,10 @@
#ifndef QTEMPORARYFILE_P_H
#define QTEMPORARYFILE_P_H
#include <QtCore/qglobal.h>
#ifndef QT_NO_TEMPORARYFILE
#include "private/qfsfileengine_p.h"
#include "private/qfilesystemengine_p.h"
#include "private/qfile_p.h"
@ -99,5 +103,7 @@ public:
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE
#endif /* QTEMPORARYFILE_P_H */

View File

@ -38,9 +38,13 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qpdf_p.h"
#ifndef QT_NO_PDF
#include "qplatformdefs.h"
#include <qdebug.h>
#include "qpdf_p.h"
#include <qfile.h>
#include <qtemporaryfile.h>
#include <private/qmath_p.h>
@ -2624,5 +2628,6 @@ void QPdfEnginePrivate::newPage()
<< "q q\n";
}
QT_END_NAMESPACE
#endif // QT_NO_PDF

View File

@ -52,6 +52,11 @@
//
// We mean it.
//
#include <QtCore/qglobal.h>
#ifndef QT_NO_PDF
#include "QtGui/qmatrix.h"
#include "QtCore/qstring.h"
#include "QtCore/qvector.h"
@ -328,5 +333,7 @@ void QPdfEngine::setResolution(int resolution)
QT_END_NAMESPACE
#endif // QT_NO_PDF
#endif // QPDF_P_H

View File

@ -40,6 +40,9 @@
****************************************************************************/
#include <qpdfwriter.h>
#ifndef QT_NO_PDF
#include <QtCore/private/qobject_p.h>
#include "private/qpdf_p.h"
#include <QtCore/qfile.h>
@ -214,3 +217,5 @@ void QPdfWriter::setMargins(const Margins &m)
}
QT_END_NAMESPACE
#endif // QT_NO_PDF

View File

@ -42,12 +42,15 @@
#ifndef QPDFWRITER_H
#define QPDFWRITER_H
#include <QtCore/qglobal.h>
#ifndef QT_NO_PDF
#include <QtCore/qobject.h>
#include <QtGui/qpagedpaintdevice.h>
QT_BEGIN_NAMESPACE
class QIODevice;
class QPdfWriterPrivate;
@ -83,4 +86,6 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_PDF
#endif

View File

@ -91,6 +91,8 @@ static const unsigned short symbol_map[0x100] = {
// ---------------------------- PS/PDF helper methods -----------------------------------
#ifndef QT_NO_PDF
QByteArray QFontSubset::glyphName(unsigned short unicode, bool symbol)
{
if (symbol && unicode < 0x100)
@ -311,6 +313,7 @@ int QFontSubset::addGlyph(int index)
return idx;
}
#endif // QT_NO_PDF
// ------------------------------ Truetype generation ----------------------------------------------

View File

@ -62,13 +62,19 @@ class QFontSubset
public:
explicit QFontSubset(QFontEngine *fe, int obj_id = 0)
: object_id(obj_id), noEmbed(false), fontEngine(fe), downloaded_glyphs(0), standard_font(false)
{ fontEngine->ref.ref(); addGlyph(0); }
{
fontEngine->ref.ref();
#ifndef QT_NO_PDF
addGlyph(0);
#endif
}
~QFontSubset() {
if (!fontEngine->ref.deref())
delete fontEngine;
}
QByteArray toTruetype() const;
#ifndef QT_NO_PDF
QByteArray widthArray() const;
QByteArray createToUnicodeMap() const;
QVector<int> getReverseMap() const;
@ -77,6 +83,7 @@ public:
static QByteArray glyphName(unsigned short unicode, bool symbol);
int addGlyph(int index);
#endif
const int object_id;
bool noEmbed;
QFontEngine *fontEngine;