summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-11-18 16:21:07 (GMT)
committermread <qt-info@nokia.com>2011-11-21 09:18:00 (GMT)
commitbd5dfa8fd2f4d5dc4a1fe0984a53b966cff6470f (patch)
tree76f1e7ef0a0a164d2d1d0dc289a0982ea0547b66 /src/corelib/global
parent52a93f068d2869fbe4e4deae2ed704d683e12834 (diff)
downloadQt-bd5dfa8fd2f4d5dc4a1fe0984a53b966cff6470f.zip
Qt-bd5dfa8fd2f4d5dc4a1fe0984a53b966cff6470f.tar.gz
Qt-bd5dfa8fd2f4d5dc4a1fe0984a53b966cff6470f.tar.bz2
Surviving out of memory in Qt Quick app
The QtQuickPlayground app contains a version of samegame which allow the user to edit the code. By setting the ball size to 8, the app can run out of memory. This leaves it in a pretty bad state. But apps on Symbian shouldn't crash due to OOM and should allow some operation. This change fixes the immediate OOM crashes in declarative, gui and corelib. It shows warning dialogs which explain what has gone wrong and leaves the app in a state that can be exited cleanly from the Symbian task list. Task-number: QT-5319 Reviewed-by: Shane Kearns Reviewed-by: Gareth Stockwell Reviewed-by: Martin Jones
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 84d68e5..3675fc7 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2207,16 +2207,13 @@ void qt_message_output(QtMsgType msgType, const char *buf)
OutputDebugString(reinterpret_cast<const wchar_t *> (fstr.utf16()));
#elif defined(Q_OS_SYMBIAN)
// RDebug::Print has a cap of 256 characters so break it up
- _LIT(format, "[Qt Message] %S");
- const int maxBlockSize = 256 - ((const TDesC &)format).Length();
+ char format[] = "[Qt Message] %S";
+ const int maxBlockSize = 256 - sizeof(format);
const TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
- 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);
+ for (int i = 0; i < ptr.Length(); i += maxBlockSize) {
+ TPtrC8 part(ptr.Mid(i, qMin(maxBlockSize, ptr.Length()-i)));
+ RDebug::Printf(format, &part);
}
- delete hbuffer;
#else
fprintf(stderr, "%s\n", buf);
fflush(stderr);