summaryrefslogtreecommitdiff
authorzecke <zecke>2003-09-03 18:58:20 (UTC)
committer zecke <zecke>2003-09-03 18:58:20 (UTC)
commit3038503f6ffc2d58b00650d5feae23cc8e842bcb (patch) (side-by-side diff)
tree33b2b319307b9a5abda47b51c31329131295d703
parent577cdc4f2ce81eaceb132af08d8ab6fe12b4eadc (diff)
downloadopie-3038503f6ffc2d58b00650d5feae23cc8e842bcb.zip
opie-3038503f6ffc2d58b00650d5feae23cc8e842bcb.tar.gz
opie-3038503f6ffc2d58b00650d5feae23cc8e842bcb.tar.bz2
Failure free restart of the launcher and a comment
why we do that
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/serverapp.cpp19
-rw-r--r--core/launcher/systray.cpp8
-rw-r--r--core/launcher/systray.h1
3 files changed, 28 insertions, 0 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index 522ef07..28316a4 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -714,27 +714,46 @@ void ServerApplication::shutdown( ShutdownImpl::Type t )
// clipboard applet has to stop its poll timer, or Qt/E
// will hang on quit() right before it emits aboutToQuit()
emit aboutToQuit ( );
quit();
break;
}
}
void ServerApplication::restart()
{
if ( allowRestart ) {
+
+ /*
+ * Applets and restart is a problem. Some applets delete
+ * their widgets even if ownership gets transfered to the
+ * parent (Systray ) but deleting the applet may be unsafe
+ * as well ( double deletion ). Some have topLevel widgets
+ * and when we dlclose and then delete the widget we will
+ * crash and an crash during restart is not nice
+ */
+#ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED
+ /* same as above */
+ emit aboutToQuit();
prepareForTermination(TRUE);
doRestart = TRUE;
quit();
+#else
+ prepareForTermination( true );
+ for ( int fd = 3; fd < 100; fd++ )
+ close( fd );
+ execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
+ exit( 1 );
+#endif
}
}
void ServerApplication::rereadVolumes()
{
Config cfg( "qpe" );
cfg. setGroup ( "Volume" );
m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
}
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp
index 64356ca..6122770 100644
--- a/core/launcher/systray.cpp
+++ b/core/launcher/systray.cpp
@@ -60,24 +60,32 @@ static int compareAppletPositions(const void *a, const void *b)
void SysTray::loadApplets()
{
hide();
clearApplets();
addApplets();
}
void SysTray::clearApplets()
{
#ifndef QT_NO_COMPONENTS
+ /*
+ * Note on clearing. SOme applets delete their
+ * applets themselves some don't do it
+ * and on restart this can crash. If we delete it
+ * here we might end up in a double deletion. We could
+ * use QGuardedPtr but that would be one QOBject
+ * for every applet more but only useful for restart
+ */
QValueList<TaskbarApplet>::Iterator mit;
for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) {
(*mit).iface->release();
(*mit).library->unload();
delete (*mit).library;
}
#endif
appletList.clear();
if ( layout )
delete layout;
layout = new QHBoxLayout( this, 0, 1 );
diff --git a/core/launcher/systray.h b/core/launcher/systray.h
index 77c581f..b989d58 100644
--- a/core/launcher/systray.h
+++ b/core/launcher/systray.h
@@ -18,24 +18,25 @@
**
**********************************************************************/
#ifndef __SYSTRAY_H__
#define __SYSTRAY_H__
#ifndef QT_NO_COMPONENT
#include <qtopia/taskbarappletinterface.h>
#endif
#include <qframe.h>
#include <qvaluelist.h>
+#include <qguardedptr.h>
class QHBoxLayout;
class QLibrary;
struct TaskbarApplet
{
#ifndef QT_NO_COMPONENT
QLibrary *library;
TaskbarAppletInterface *iface;
#endif
QWidget *applet;
QString name;