diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-11-03 12:03:11 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@sosco.com> | 2009-11-03 12:55:19 (GMT) |
commit | 3769f290ccc20ff92dd43038743f96097d9fabd0 (patch) | |
tree | eaa0c7b9f8ad4ec18a7bec2efab170330cc4d51d /src | |
parent | 5308b1c607c1209822078d8aae329308c8017636 (diff) | |
download | Qt-3769f290ccc20ff92dd43038743f96097d9fabd0.zip Qt-3769f290ccc20ff92dd43038743f96097d9fabd0.tar.gz Qt-3769f290ccc20ff92dd43038743f96097d9fabd0.tar.bz2 |
Fix cleanupstack crash on exit in Symbian OS 9.2
Destroying the control environment also pops items from the original
cleanup stack which is not owned by the control environment.
This is a platform issue (and does not occur in 9.3 & 9.4).
To avoid this causing a panic, the s60main is changed to not push items
on the cleanup stack (instead, it TRAPs the call to main(), and deletes
its allocations manually).
A further 9.2 cleanup stack crash was caused when application construction
fails (because of missing resource files). The resulting exception would
bypass deleting the control environment, and return from main with the
wrong cleanup stack active.
This is resolved by doing the TRAP / cleanup / throw manually instead of
using qt_trap_throwing (The control environment cannot be pushed to the
cleanup stack, because it owns the cleanup stack at that time).
This isn't a 9.2 specific bug, but rather is revealed by 9.2 because the
missing resource file is non fatal in 9.3 and 9.4.
Fixes many autotests which have crashed on S60 3.1 since the cleanup
stack swapping patch.
Reviewed-by: axis
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 11 | ||||
-rw-r--r-- | src/s60main/qts60main_mcrt0.cpp | 8 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e5ee2f1..1b0659a 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1052,8 +1052,17 @@ void qt_init(QApplicationPrivate * /* priv */, int) // After this construction, CEikonEnv will be available from CEikonEnv::Static(). // (much like our qApp). CEikonEnv* coe = new CEikonEnv; - QT_TRAP_THROWING(coe->ConstructAppFromCommandLineL(factory,*commandLine)); + //not using QT_TRAP_THROWING, because coe owns the cleanupstack so it can't be pushed there. + if(err == KErrNone) + TRAP(err, coe->ConstructAppFromCommandLineL(factory,*commandLine)); delete commandLine; + if(err != KErrNone) { + qWarning() << "qt_init: Eikon application construct failed (" + << err + << "), maybe missing resource file on S60 3.1?"; + delete coe; + qt_symbian_throwIfError(err); + } S60->s60InstalledTrapHandler = User::SetTrapHandler(origTrapHandler); diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index d30e07a..edc2fb8 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -83,12 +83,10 @@ GLDEF_C TInt QtMainWrapper() char **envp = 0; // get args & environment __crt0(argc, argv, envp); - CleanupArrayDelete<char*>::PushL(argv); - CleanupArrayDelete<char*>::PushL(envp); //Call user(application)'s main - int ret = 0; - QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp);); - CleanupStack::PopAndDestroy(2, argv); + TRAPD(ret, QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp);)); + delete[] argv; + delete[] envp; return ret; } |