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 #define QT_NO_LOCALSERVER
#endif #endif
// QPdf
#if !defined(QT_NO_PDF) && (defined(QT_NO_TEMPORARYFILE))
#define QT_NO_PDF
#endif
// QMenu // QMenu
#if !defined(QT_NO_MENU) && (defined(QT_NO_ACTION)) #if !defined(QT_NO_MENU) && (defined(QT_NO_ACTION))
#define QT_NO_MENU #define QT_NO_MENU

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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