summaryrefslogtreecommitdiff
authorzecke <zecke>2003-09-03 18:58:20 (UTC)
committer zecke <zecke>2003-09-03 18:58:20 (UTC)
commit3038503f6ffc2d58b00650d5feae23cc8e842bcb (patch) (unidiff)
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
@@ -702,51 +702,70 @@ void ServerApplication::shutdown( ShutdownImpl::Type t )
702 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) 702 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 )
703 perror("shutdown"); 703 perror("shutdown");
704 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); 704 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
705 705
706 break; 706 break;
707 case ShutdownImpl::RestartDesktop: 707 case ShutdownImpl::RestartDesktop:
708 restart(); 708 restart();
709 break; 709 break;
710 case ShutdownImpl::TerminateDesktop: 710 case ShutdownImpl::TerminateDesktop:
711 prepareForTermination( FALSE ); 711 prepareForTermination( FALSE );
712 712
713 // This is a workaround for a Qt bug 713 // This is a workaround for a Qt bug
714 // clipboard applet has to stop its poll timer, or Qt/E 714 // clipboard applet has to stop its poll timer, or Qt/E
715 // will hang on quit() right before it emits aboutToQuit() 715 // will hang on quit() right before it emits aboutToQuit()
716 emit aboutToQuit ( ); 716 emit aboutToQuit ( );
717 717
718 quit(); 718 quit();
719 break; 719 break;
720 } 720 }
721} 721}
722 722
723void ServerApplication::restart() 723void ServerApplication::restart()
724{ 724{
725 if ( allowRestart ) { 725 if ( allowRestart ) {
726
727 /*
728 * Applets and restart is a problem. Some applets delete
729 * their widgets even if ownership gets transfered to the
730 * parent (Systray ) but deleting the applet may be unsafe
731 * as well ( double deletion ). Some have topLevel widgets
732 * and when we dlclose and then delete the widget we will
733 * crash and an crash during restart is not nice
734 */
735#ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED
736 /* same as above */
737 emit aboutToQuit();
726 prepareForTermination(TRUE); 738 prepareForTermination(TRUE);
727 doRestart = TRUE; 739 doRestart = TRUE;
728 quit(); 740 quit();
741#else
742 prepareForTermination( true );
743 for ( int fd = 3; fd < 100; fd++ )
744 close( fd );
745 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
746 exit( 1 );
747#endif
729 } 748 }
730} 749}
731 750
732void ServerApplication::rereadVolumes() 751void ServerApplication::rereadVolumes()
733{ 752{
734 Config cfg( "qpe" ); 753 Config cfg( "qpe" );
735 cfg. setGroup ( "Volume" ); 754 cfg. setGroup ( "Volume" );
736 755
737 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); 756 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
738 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); 757 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
739 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); 758 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
740} 759}
741 760
742 761
743void ServerApplication::checkMemory() 762void ServerApplication::checkMemory()
744{ 763{
745#if defined(QPE_HAVE_MEMALERTER) 764#if defined(QPE_HAVE_MEMALERTER)
746 static bool ignoreNormal=TRUE; 765 static bool ignoreNormal=TRUE;
747 static bool existingMessage=FALSE; 766 static bool existingMessage=FALSE;
748 767
749 if(existingMessage) 768 if(existingMessage)
750 return; // don't show a second message while still on first 769 return; // don't show a second message while still on first
751 770
752 existingMessage = TRUE; 771 existingMessage = TRUE;
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
@@ -48,48 +48,56 @@ SysTray::~SysTray()
48{ 48{
49 clearApplets(); 49 clearApplets();
50} 50}
51 51
52static int compareAppletPositions(const void *a, const void *b) 52static int compareAppletPositions(const void *a, const void *b)
53{ 53{
54 const TaskbarApplet* aa = *(const TaskbarApplet**)a; 54 const TaskbarApplet* aa = *(const TaskbarApplet**)a;
55 const TaskbarApplet* ab = *(const TaskbarApplet**)b; 55 const TaskbarApplet* ab = *(const TaskbarApplet**)b;
56 int d = ab->iface->position() - aa->iface->position(); 56 int d = ab->iface->position() - aa->iface->position();
57 if ( d ) return d; 57 if ( d ) return d;
58 return QString::compare(ab->name,aa->name); 58 return QString::compare(ab->name,aa->name);
59} 59}
60 60
61void SysTray::loadApplets() 61void SysTray::loadApplets()
62{ 62{
63 hide(); 63 hide();
64 clearApplets(); 64 clearApplets();
65 addApplets(); 65 addApplets();
66} 66}
67 67
68void SysTray::clearApplets() 68void SysTray::clearApplets()
69{ 69{
70#ifndef QT_NO_COMPONENTS 70#ifndef QT_NO_COMPONENTS
71 71
72 /*
73 * Note on clearing. SOme applets delete their
74 * applets themselves some don't do it
75 * and on restart this can crash. If we delete it
76 * here we might end up in a double deletion. We could
77 * use QGuardedPtr but that would be one QOBject
78 * for every applet more but only useful for restart
79 */
72 QValueList<TaskbarApplet>::Iterator mit; 80 QValueList<TaskbarApplet>::Iterator mit;
73 for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { 81 for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) {
74 (*mit).iface->release(); 82 (*mit).iface->release();
75 (*mit).library->unload(); 83 (*mit).library->unload();
76 delete (*mit).library; 84 delete (*mit).library;
77 } 85 }
78 86
79#endif 87#endif
80 appletList.clear(); 88 appletList.clear();
81 if ( layout ) 89 if ( layout )
82 delete layout; 90 delete layout;
83 layout = new QHBoxLayout( this, 0, 1 ); 91 layout = new QHBoxLayout( this, 0, 1 );
84 layout->setAutoAdd(TRUE); 92 layout->setAutoAdd(TRUE);
85} 93}
86 94
87void SysTray::addApplets() 95void SysTray::addApplets()
88{ 96{
89 hide(); 97 hide();
90#ifndef QT_NO_COMPONENTS 98#ifndef QT_NO_COMPONENTS
91 Config cfg( "Taskbar" ); 99 Config cfg( "Taskbar" );
92 cfg.setGroup( "Applets" ); 100 cfg.setGroup( "Applets" );
93 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 101 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
94 102
95 QString lang = getenv( "LANG" ); 103 QString lang = getenv( "LANG" );
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
@@ -6,48 +6,49 @@
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __SYSTRAY_H__ 21#ifndef __SYSTRAY_H__
22#define __SYSTRAY_H__ 22#define __SYSTRAY_H__
23 23
24#ifndef QT_NO_COMPONENT 24#ifndef QT_NO_COMPONENT
25#include <qtopia/taskbarappletinterface.h> 25#include <qtopia/taskbarappletinterface.h>
26#endif 26#endif
27 27
28#include <qframe.h> 28#include <qframe.h>
29#include <qvaluelist.h> 29#include <qvaluelist.h>
30#include <qguardedptr.h>
30 31
31class QHBoxLayout; 32class QHBoxLayout;
32class QLibrary; 33class QLibrary;
33 34
34struct TaskbarApplet 35struct TaskbarApplet
35{ 36{
36#ifndef QT_NO_COMPONENT 37#ifndef QT_NO_COMPONENT
37 QLibrary *library; 38 QLibrary *library;
38 TaskbarAppletInterface *iface; 39 TaskbarAppletInterface *iface;
39#endif 40#endif
40 QWidget *applet; 41 QWidget *applet;
41 QString name; 42 QString name;
42}; 43};
43 44
44class SysTray : public QFrame { 45class SysTray : public QFrame {
45 Q_OBJECT 46 Q_OBJECT
46public: 47public:
47 SysTray( QWidget *parent ); 48 SysTray( QWidget *parent );
48 ~SysTray(); 49 ~SysTray();
49 50
50 void clearApplets(); 51 void clearApplets();
51 void addApplets(); 52 void addApplets();
52 53
53private: 54private: