summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-19 12:27:59 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-19 12:27:59 (GMT)
commit129a44a9cea98c4e3d24a2b890c20ff154c87172 (patch)
treeda2f5bde4d37c291053f4584fa84de0fd48df4d6
parentffbce9839f8be5c2f21cc66b617dbeb0a47af269 (diff)
parent5e7e6788814549a1b60f9cc8972e03fb8a830d1c (diff)
downloadQt-129a44a9cea98c4e3d24a2b890c20ff154c87172.zip
Qt-129a44a9cea98c4e3d24a2b890c20ff154c87172.tar.gz
Qt-129a44a9cea98c4e3d24a2b890c20ff154c87172.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: qUncompress: don't exit on allocation failure with -no-exceptions Prefer Q_CHECK_PTR to q_check_ptr Prefer Q_CHECK_PTR to q_check_ptr Ensure Q_CHECK_PTR always requires terminating ; Q_CHECK_PTR should issue qFatal with QT_NO_EXCEPTIONS Workaround what seems to be a compiler parser bug
-rw-r--r--src/corelib/global/qglobal.cpp5
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp3
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp6
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp3
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/tools/qbytearray.cpp12
-rw-r--r--src/corelib/tools/qstring.cpp4
-rw-r--r--src/gui/kernel/qwidget_s60.cpp8
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp3
-rw-r--r--src/gui/text/qfontengine_s60.cpp7
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp3
-rw-r--r--src/openvg/qvg_symbian.cpp9
-rw-r--r--src/s60main/qts60main.cpp3
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp36
15 files changed, 60 insertions, 46 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index af35316..a59a74f 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1984,7 +1984,7 @@ QSysInfo::SymbianVersion QSysInfo::symbianVersion()
*/
void qt_check_pointer(const char *n, int l)
{
- qWarning("In file %s, line %d: Out of memory", n, l);
+ qFatal("In file %s, line %d: Out of memory", n, l);
}
/* \internal
@@ -2215,7 +2215,8 @@ void qt_message_output(QtMsgType msgType, const char *buf)
_LIT(format, "[Qt Message] %S");
const int maxBlockSize = 256 - ((const TDesC &)format).Length();
const TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
- HBufC* hbuffer = q_check_ptr(HBufC::New(qMin(maxBlockSize, ptr.Length())));
+ HBufC* hbuffer = HBufC::New(qMin(maxBlockSize, ptr.Length()));
+ Q_CHECK_PTR(hbuffer);
for (int i = 0; i < ptr.Length(); i += hbuffer->Length()) {
hbuffer->Des().Copy(ptr.Mid(i, qMin(maxBlockSize, ptr.Length()-i)));
RDebug::Print(format, hbuffer);
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 0e0eecd..a8758cf 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1690,7 +1690,7 @@ Q_CORE_EXPORT void qBadAlloc();
#ifdef QT_NO_EXCEPTIONS
# if defined(QT_NO_DEBUG)
-# define Q_CHECK_PTR(p) qt_noop();
+# define Q_CHECK_PTR(p) qt_noop()
# else
# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
# endif
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 4764a46..774932a 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1092,7 +1092,8 @@ QString QFSFileEngine::fileName(FileName file) const
int size = PATH_CHUNK_SIZE;
while (1) {
- s = q_check_ptr((char *) ::realloc(s, size));
+ s = (char *) ::realloc(s, size);
+ Q_CHECK_PTR(s);
len = ::readlink(d->nativeFilePath.constData(), s, size);
if (len < 0) {
::free(s);
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index 5afde9a..073ed6b 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -61,7 +61,8 @@ Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString)
#else
TPtrC16 ptr(qt_QString2TPtrC(aString));
#endif
- buffer = q_check_ptr(HBufC::New(ptr.Length()));
+ buffer = HBufC::New(ptr.Length());
+ Q_CHECK_PTR(buffer);
buffer->Des().Copy(ptr);
return buffer;
}
@@ -81,8 +82,9 @@ QHBufC::QHBufC()
}
QHBufC::QHBufC(const QHBufC &src)
- : m_hBufC(q_check_ptr(src.m_hBufC->Alloc()))
+ : m_hBufC(src.m_hBufC->Alloc())
{
+ Q_CHECK_PTR(m_hBufC);
}
/*!
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 1bad8ed..5ab867f 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -1009,7 +1009,8 @@ bool QEventDispatcherSymbian::hasPendingEvents()
void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier )
{
- QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier));
+ QSocketActiveObject *socketAO = new QSocketActiveObject(this, notifier);
+ Q_CHECK_PTR(socketAO);
m_notifiers.insert(notifier, socketAO);
selectThread().requestSocketEvents(notifier, &socketAO->iStatus);
}
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 432b708..a4d45f6 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -589,7 +589,7 @@ inline QT_DEPRECATED T qVariantValue(const QVariant &variant)
template<typename T>
inline QT_DEPRECATED bool qVariantCanConvert(const QVariant &variant)
-{ return variant.canConvert<T>(); }
+{ return variant.template canConvert<T>(); }
#endif
#endif
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 8d38e4c..3062c4a 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -542,12 +542,14 @@ QByteArray qUncompress(const uchar* data, int nbytes)
forever {
ulong alloc = len;
- d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.take(), sizeof(QByteArray::Data) + alloc))));
- if (!d) {
+ QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc));
+ if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
qWarning("qUncompress: could not allocate enough memory to uncompress data");
return QByteArray();
}
+ d.take(); // realloc was successful
+ d.reset(p);
int res = ::uncompress((uchar*)d->array, &len,
(uchar*)data+4, nbytes-4);
@@ -555,12 +557,14 @@ QByteArray qUncompress(const uchar* data, int nbytes)
switch (res) {
case Z_OK:
if (len != alloc) {
- d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.take(), sizeof(QByteArray::Data) + len))));
- if (!d) {
+ QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len));
+ if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
qWarning("qUncompress: could not allocate enough memory to uncompress data");
return QByteArray();
}
+ d.take(); // realloc was successful
+ d.reset(p);
}
d->ref = 1;
d->alloc = d->size = len;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 7bc9ca1..7ea9877 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1298,7 +1298,9 @@ void QString::realloc(int alloc)
asciiCache->remove(d);
}
#endif
- d = static_cast<Data *>(q_check_ptr(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar))));
+ Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
+ Q_CHECK_PTR(p);
+ d = p;
d->alloc = alloc;
d->data = d->array;
}
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 56349ad..5075803 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -360,7 +360,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen))
data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY));
- QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
+ QScopedPointer<QSymbianControl> control( new QSymbianControl(q) );
+ Q_CHECK_PTR(control);
+
QT_TRAP_THROWING(control->ConstructL(true, desktop));
control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi()));
@@ -405,7 +407,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget
- QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
+ QScopedPointer<QSymbianControl> control( new QSymbianControl(q) );
+ Q_CHECK_PTR(control);
+
QT_TRAP_THROWING(control->ConstructL(!parentWidget));
// Symbian windows are always created in an inactive state
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index 8bac1f5..d4dcf7d 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -77,7 +77,8 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget)
}
// We create empty CFbsBitmap here -> it will be resized in setGeometry
- CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new
+ CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new
+ Q_CHECK_PTR(bitmap);
qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index 52a1fe7..a25970b 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -122,7 +122,8 @@ QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const
Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag));
TInt error = KErrNone;
TInt tableByteLength = 0;
- TAny *table = q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength));
+ TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength);
+ Q_CHECK_PTR(table);
QByteArray result(static_cast<const char*>(table), tableByteLength);
m_trueTypeExtension->ReleaseTrueTypeTable(table);
return result;
@@ -136,8 +137,8 @@ bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *len
bool result = true;
TInt error = KErrNone;
TInt tableByteLength;
- TAny *table =
- q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength));
+ TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength);
+ Q_CHECK_PTR(table);
if (error != KErrNone) {
return false;
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index ab2bdea..c643a1e 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -264,7 +264,8 @@ void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id)
// However if we don't have any items, we still need the item array. Otherwise
// menupane will crash. That's why we create item array here manually, and
// AddMenuItemL will then use the existing array.
- CEikMenuPane::CItemArray* itemArray = q_check_ptr(new CEikMenuPane::CItemArray);
+ CEikMenuPane::CItemArray* itemArray = new CEikMenuPane::CItemArray;
+ Q_CHECK_PTR(itemArray);
menuPane->SetItemArray(itemArray);
menuPane->SetItemArrayOwnedExternally(EFalse);
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
index 0e6e773..0d2425f 100644
--- a/src/openvg/qvg_symbian.cpp
+++ b/src/openvg/qvg_symbian.cpp
@@ -77,7 +77,8 @@ extern int qt_vg_pixmap_serial;
static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap)
{
- CFbsBitmap *copy = q_check_ptr(new CFbsBitmap);
+ CFbsBitmap *copy = new CFbsBitmap;
+ Q_CHECK_PTR(copy);
if(!copy)
return 0;
@@ -255,7 +256,8 @@ void* QVGPixmapData::toNativeType(NativeType type)
sgInfo.iSizeInPixels.SetSize(w, h);
sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
- RSgImage *sgImage = q_check_ptr(new RSgImage());
+ RSgImage *sgImage = new RSgImage();
+ Q_CHECK_PTR(sgImage);
err = sgImage->Create(sgInfo, NULL, NULL);
if (err != KErrNone) {
driver.Close();
@@ -297,7 +299,8 @@ void* QVGPixmapData::toNativeType(NativeType type)
return reinterpret_cast<void*>(sgImage);
#endif
} else if (type == QPixmapData::FbsBitmap) {
- CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);
+ CFbsBitmap *bitmap = new CFbsBitmap;
+ Q_CHECK_PTR(bitmap);
if (bitmap) {
if (bitmap->Create(TSize(source.width(), source.height()),
diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp
index 5fbeea5..c65344b 100644
--- a/src/s60main/qts60main.cpp
+++ b/src/s60main/qts60main.cpp
@@ -51,7 +51,8 @@ GLDEF_C TInt QtMainWrapper();
*/
GLDEF_C TInt E32Main()
{
- CTrapCleanup *cleanupStack = q_check_ptr(CTrapCleanup::New());
+ CTrapCleanup *cleanupStack = CTrapCleanup::New();
+ Q_CHECK_PTR(cleanupStack);
TInt err = 0;
TRAP(err, err = QtMainWrapper());
delete cleanupStack;
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index e3341d1..0dc2282 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -223,18 +223,18 @@ void tst_QByteArray::qUncompress_data()
QTest::addColumn<QByteArray>("in");
QTest::addColumn<QByteArray>("out");
- QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00") << QByteArray();
- QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff") << QByteArray();
- QTest::newRow("0x3f000000") << QByteArray("\x3f\x00\x00\x00") << QByteArray();
- QTest::newRow("0x3fffffff") << QByteArray("\x3f\xff\xff\xff") << QByteArray();
- QTest::newRow("0x7fffff00") << QByteArray("\x7f\xff\xff\x00") << QByteArray();
- QTest::newRow("0x7fffffff") << QByteArray("\x7f\xff\xff\xff") << QByteArray();
- QTest::newRow("0x80000000") << QByteArray("\x80\x00\x00\x00") << QByteArray();
- QTest::newRow("0x800000ff") << QByteArray("\x80\x00\x00\xff") << QByteArray();
- QTest::newRow("0xcf000000") << QByteArray("\xcf\x00\x00\x00") << QByteArray();
- QTest::newRow("0xcfffffff") << QByteArray("\xcf\xff\xff\xff") << QByteArray();
- QTest::newRow("0xffffff00") << QByteArray("\xff\xff\xff\x00") << QByteArray();
- QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff") << QByteArray();
+ QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00", 4) << QByteArray();
+ QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff", 4) << QByteArray();
+ QTest::newRow("0x3f000000") << QByteArray("\x3f\x00\x00\x00", 4) << QByteArray();
+ QTest::newRow("0x3fffffff") << QByteArray("\x3f\xff\xff\xff", 4) << QByteArray();
+ QTest::newRow("0x7fffff00") << QByteArray("\x7f\xff\xff\x00", 4) << QByteArray();
+ QTest::newRow("0x7fffffff") << QByteArray("\x7f\xff\xff\xff", 4) << QByteArray();
+ QTest::newRow("0x80000000") << QByteArray("\x80\x00\x00\x00", 4) << QByteArray();
+ QTest::newRow("0x800000ff") << QByteArray("\x80\x00\x00\xff", 4) << QByteArray();
+ QTest::newRow("0xcf000000") << QByteArray("\xcf\x00\x00\x00", 4) << QByteArray();
+ QTest::newRow("0xcfffffff") << QByteArray("\xcf\xff\xff\xff", 4) << QByteArray();
+ QTest::newRow("0xffffff00") << QByteArray("\xff\xff\xff\x00", 4) << QByteArray();
+ QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff", 4) << QByteArray();
}
void tst_QByteArray::qUncompress()
@@ -251,18 +251,10 @@ void tst_QByteArray::qUncompress()
#endif
QByteArray res;
- QT_TRY {
- res = ::qUncompress(in);
- } QT_CATCH(const std::bad_alloc &) {
- res = QByteArray();
- }
+ res = ::qUncompress(in);
QCOMPARE(res, out);
- QT_TRY {
- res = ::qUncompress(in + "blah");
- } QT_CATCH(const std::bad_alloc &) {
- res = QByteArray();
- }
+ res = ::qUncompress(in + "blah");
QCOMPARE(res, out);
}