-rw-r--r-- | core/tools/quicklauncher/dropins.h | 9 | ||||
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 10 |
2 files changed, 11 insertions, 8 deletions
diff --git a/core/tools/quicklauncher/dropins.h b/core/tools/quicklauncher/dropins.h index 7acace9..a9664f8 100644 --- a/core/tools/quicklauncher/dropins.h +++ b/core/tools/quicklauncher/dropins.h | |||
@@ -1,68 +1,71 @@ | |||
1 | /* OPIE */ | ||
2 | #include <opie2/owait.h> | ||
3 | using namespace Opie::Ui; | ||
1 | 4 | ||
2 | #include <qstring.h> | ||
3 | #include <qtopia/qcom.h> | 5 | #include <qtopia/qcom.h> |
4 | #include <qtopia/qlibrary.h> | 6 | #include <qtopia/qlibrary.h> |
7 | #include <qtopia/qpeapplication.h> | ||
5 | #include <qtopia/applicationinterface.h> | 8 | #include <qtopia/applicationinterface.h> |
6 | #include <qtopia/resource.h> | 9 | #include <qtopia/resource.h> |
7 | 10 | ||
8 | #include <opie2/owait.h> | 11 | /* QT */ |
9 | |||
10 | #include <qmetaobject.h> | 12 | #include <qmetaobject.h> |
11 | #include <qmap.h> | 13 | #include <qmap.h> |
14 | #include <qstring.h> | ||
12 | 15 | ||
13 | namespace QuickPrivate { | 16 | namespace QuickPrivate { |
14 | 17 | ||
15 | struct PluginLoader { | 18 | struct PluginLoader { |
16 | PluginLoader( const char* ) { | 19 | PluginLoader( const char* ) { |
17 | } | 20 | } |
18 | 21 | ||
19 | QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** ); | 22 | QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** ); |
20 | void releaseInterface( QUnknownInterface* ); | 23 | void releaseInterface( QUnknownInterface* ); |
21 | QMap<QUnknownInterface*, QLibrary*> libs; | 24 | QMap<QUnknownInterface*, QLibrary*> libs; |
22 | }; | 25 | }; |
23 | 26 | ||
24 | /* | 27 | /* |
25 | * We can skip installing a Translator here because Opies QPEApplication | 28 | * We can skip installing a Translator here because Opies QPEApplication |
26 | * will do that in initApp for us as well | 29 | * will do that in initApp for us as well |
27 | */ | 30 | */ |
28 | QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) { | 31 | QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) { |
29 | QRESULT res = QS_FALSE; | 32 | QRESULT res = QS_FALSE; |
30 | *iface = 0; | 33 | *iface = 0; |
31 | 34 | ||
32 | // This code is very platform specific.. We should find better | 35 | // This code is very platform specific.. We should find better |
33 | // solutions to handle names.. Maybe one central function would be | 36 | // solutions to handle names.. Maybe one central function would be |
34 | // better than checking this ".so" stuff all around in the sources.. | 37 | // better than checking this ".so" stuff all around in the sources.. |
35 | // (eilers) | 38 | // (eilers) |
36 | 39 | ||
37 | // Below lines from TT then mine again | 40 | // Below lines from TT then mine again |
38 | QString name = libFile; | 41 | QString name = libFile; |
39 | if ( libFile.findRev(".so") == (int)libFile.length()-3 ) { | 42 | if ( libFile.findRev(".so") == (int)libFile.length()-3 ) { |
40 | name = libFile.left( libFile.length()-3 ); | 43 | name = libFile.left( libFile.length()-3 ); |
41 | if ( name.find( "lib" ) == 0 ) | 44 | if ( name.find( "lib" ) == 0 ) |
42 | name = name.mid( 3 ); | 45 | name = name.mid( 3 ); |
43 | } | 46 | } |
44 | #ifdef Q_OS_MACX | 47 | #ifdef Q_OS_MACX |
45 | QString path = QPEApplication::qpeDir() + "/plugins/application/lib"+name+".dylib"; | 48 | QString path = QPEApplication::qpeDir() + "/plugins/application/lib"+name+".dylib"; |
46 | #else | 49 | #else |
47 | QString path = QPEApplication::qpeDir() + "/plugins/application/lib"+name+".so"; | 50 | QString path = QPEApplication::qpeDir() + "/plugins/application/lib"+name+".so"; |
48 | #endif | 51 | #endif |
49 | 52 | ||
50 | QLibrary *lib = new QLibrary( path ); | 53 | QLibrary *lib = new QLibrary( path ); |
51 | if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) { | 54 | if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) { |
52 | libs.insert( *iface, lib ); | 55 | libs.insert( *iface, lib ); |
53 | res = QS_OK; | 56 | res = QS_OK; |
54 | } | 57 | } |
55 | 58 | ||
56 | return res; | 59 | return res; |
57 | } | 60 | } |
58 | 61 | ||
59 | void PluginLoader::releaseInterface( QUnknownInterface* iface ) { | 62 | void PluginLoader::releaseInterface( QUnknownInterface* iface ) { |
60 | if ( libs.contains( iface ) ) { | 63 | if ( libs.contains( iface ) ) { |
61 | iface->release(); | 64 | iface->release(); |
62 | delete libs[iface]; | 65 | delete libs[iface]; |
63 | libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is | 66 | libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is |
64 | } | 67 | } |
65 | } | 68 | } |
66 | 69 | ||
67 | } | 70 | } |
68 | 71 | ||
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp index c2467fb..b1befce 100644 --- a/core/tools/quicklauncher/main.cpp +++ b/core/tools/quicklauncher/main.cpp | |||
@@ -1,275 +1,275 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
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 | #define QTOPIA_INTERNAL_INITAPP | ||
21 | #include "dropins.h" | 22 | #include "dropins.h" |
22 | 23 | ||
23 | /* OPIE */ | 24 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | using namespace Opie::Core; | ||
25 | 27 | ||
26 | /* QT */ | 28 | /* QT */ |
27 | #include <qpainter.h> | 29 | #include <qpainter.h> |
28 | #include <qstrlist.h> | 30 | #include <qstrlist.h> |
29 | #include <qtimer.h> | 31 | #include <qtimer.h> |
30 | #include <qguardedptr.h> | 32 | #include <qguardedptr.h> |
31 | #include <qcopchannel_qws.h> | 33 | #include <qcopchannel_qws.h> |
32 | #define QTOPIA_INTERNAL_INITAPP | ||
33 | 34 | ||
34 | #ifdef private | 35 | #ifdef private |
35 | # undef private | 36 | # undef private |
36 | #endif | 37 | #endif |
37 | #define private public | 38 | #define private public |
38 | #include <qtopia/qpeapplication.h> | 39 | #include <qtopia/qpeapplication.h> |
39 | #undef private | 40 | #undef private |
40 | 41 | ||
41 | /* STD */ | 42 | /* STD */ |
42 | #include <stdio.h> | 43 | #include <stdio.h> |
43 | #include <stdlib.h> | 44 | #include <stdlib.h> |
44 | #include <sys/types.h> | 45 | #include <sys/types.h> |
45 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
46 | #include <unistd.h> | 47 | #include <unistd.h> |
47 | 48 | ||
48 | 49 | ||
49 | using QuickPrivate::PluginLoader; | 50 | using QuickPrivate::PluginLoader; |
50 | 51 | ||
51 | static QPEApplication *app = 0; | 52 | static QPEApplication *app = 0; |
52 | static PluginLoader *loader = 0; | 53 | static PluginLoader *loader = 0; |
53 | static ApplicationInterface *appIface = 0; | 54 | static ApplicationInterface *appIface = 0; |
54 | static QGuardedPtr<QWidget> mainWindow; | 55 | static QGuardedPtr<QWidget> mainWindow; |
55 | 56 | ||
56 | #ifdef _OS_LINUX_ | 57 | #ifdef _OS_LINUX_ |
57 | static char **argv0 = 0; | 58 | static char **argv0 = 0; |
58 | static int argv_lth; | 59 | static int argv_lth; |
59 | extern char **environ; | 60 | extern char **environ; |
60 | #ifndef SPT_BUFSIZE | 61 | #ifndef SPT_BUFSIZE |
61 | #define SPT_BUFSIZE 2048 | 62 | #define SPT_BUFSIZE 2048 |
62 | #endif | 63 | #endif |
63 | #include <stdarg.h> | 64 | #include <stdarg.h> |
64 | using namespace Opie::Ui; | ||
65 | void setproctitle (const char *fmt,...) { | 65 | void setproctitle (const char *fmt,...) { |
66 | int i; | 66 | int i; |
67 | char buf[SPT_BUFSIZE]; | 67 | char buf[SPT_BUFSIZE]; |
68 | va_list ap; | 68 | va_list ap; |
69 | 69 | ||
70 | if (!argv0) | 70 | if (!argv0) |
71 | return; | 71 | return; |
72 | 72 | ||
73 | va_start(ap, fmt); | 73 | va_start(ap, fmt); |
74 | (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); | 74 | (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); |
75 | va_end(ap); | 75 | va_end(ap); |
76 | 76 | ||
77 | i = strlen (buf); | 77 | i = strlen (buf); |
78 | if (i > argv_lth - 2) { | 78 | if (i > argv_lth - 2) { |
79 | i = argv_lth - 2; | 79 | i = argv_lth - 2; |
80 | buf[i] = '\0'; | 80 | buf[i] = '\0'; |
81 | } | 81 | } |
82 | memset(argv0[0], '\0', argv_lth); /* clear the memory area */ | 82 | memset(argv0[0], '\0', argv_lth); /* clear the memory area */ |
83 | (void) strcpy (argv0[0], buf); | 83 | (void) strcpy (argv0[0], buf); |
84 | 84 | ||
85 | argv0[1] = NULL; | 85 | argv0[1] = NULL; |
86 | } | 86 | } |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | 89 | ||
90 | class QuickLauncher : public QObject | 90 | class QuickLauncher : public QObject |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | QuickLauncher() : QObject() | 94 | QuickLauncher() : QObject() |
95 | { | 95 | { |
96 | QCString ch("QPE/QuickLauncher-"); | 96 | QCString ch("QPE/QuickLauncher-"); |
97 | ch += QString::number(getpid()); | 97 | ch += QString::number(getpid()); |
98 | qlChannel = new QCopChannel( ch, this); | 98 | qlChannel = new QCopChannel( ch, this); |
99 | connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 99 | connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
100 | this, SLOT(message(const QCString&,const QByteArray&)) ); | 100 | this, SLOT(message(const QCString&,const QByteArray&)) ); |
101 | } | 101 | } |
102 | 102 | ||
103 | static void exec( int /*argc*/, char **argv ) | 103 | static void exec( int /*argc*/, char **argv ) |
104 | { | 104 | { |
105 | QString appName = argv[0]; | 105 | QString appName = argv[0]; |
106 | int sep = appName.findRev( '/' ); | 106 | int sep = appName.findRev( '/' ); |
107 | if ( sep > 0 ) | 107 | if ( sep > 0 ) |
108 | appName = appName.mid( sep+1 ); | 108 | appName = appName.mid( sep+1 ); |
109 | 109 | ||
110 | appIface = 0; | 110 | appIface = 0; |
111 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { | 111 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { |
112 | mainWindow = appIface->createMainWindow( appName ); | 112 | mainWindow = appIface->createMainWindow( appName ); |
113 | } | 113 | } |
114 | if ( mainWindow ) { | 114 | if ( mainWindow ) { |
115 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { | 115 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { |
116 | app->showMainDocumentWidget( mainWindow ); | 116 | app->showMainDocumentWidget( mainWindow ); |
117 | } else { | 117 | } else { |
118 | app->showMainWidget( mainWindow ); | 118 | app->showMainWidget( mainWindow ); |
119 | } | 119 | } |
120 | } else { | 120 | } else { |
121 | owarn << "Could not create application main window" << oendl; | 121 | owarn << "Could not create application main window" << oendl; |
122 | exit(-1); | 122 | exit(-1); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | private slots: | 126 | private slots: |
127 | void message(const QCString &msg, const QByteArray & data) | 127 | void message(const QCString &msg, const QByteArray & data) |
128 | { | 128 | { |
129 | QStrList argList; | 129 | QStrList argList; |
130 | 130 | ||
131 | if ( msg == "execute(QStrList)" ) { | 131 | if ( msg == "execute(QStrList)" ) { |
132 | delete qlChannel; | 132 | delete qlChannel; |
133 | QDataStream stream( data, IO_ReadOnly ); | 133 | QDataStream stream( data, IO_ReadOnly ); |
134 | QStrList argList; | 134 | QStrList argList; |
135 | stream >> argList; | 135 | stream >> argList; |
136 | odebug << "QuickLauncher execute: " << argList.at(0) << "" << oendl; | 136 | odebug << "QuickLauncher execute: " << argList.at(0) << oendl; |
137 | doQuickLaunch( argList ); | 137 | doQuickLaunch( argList ); |
138 | delete this; | 138 | delete this; |
139 | } else if ( msg == "execute(QString)" ) { | 139 | } else if ( msg == "execute(QString)" ) { |
140 | delete qlChannel; | 140 | delete qlChannel; |
141 | QDataStream stream( data, IO_ReadOnly ); | 141 | QDataStream stream( data, IO_ReadOnly ); |
142 | QString arg; | 142 | QString arg; |
143 | stream >> arg; | 143 | stream >> arg; |
144 | odebug << "QuickLauncher execute: " << arg << "" << oendl; | 144 | odebug << "QuickLauncher execute: " << arg << oendl; |
145 | QStrList argList; | 145 | QStrList argList; |
146 | argList.append( arg.utf8() ); | 146 | argList.append( arg.utf8() ); |
147 | doQuickLaunch( argList ); | 147 | doQuickLaunch( argList ); |
148 | delete this; | 148 | delete this; |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | private: | 152 | private: |
153 | void doQuickLaunch( QStrList &argList ) | 153 | void doQuickLaunch( QStrList &argList ) |
154 | { | 154 | { |
155 | static int myargc = argList.count(); | 155 | static int myargc = argList.count(); |
156 | static char **myargv = new char *[myargc + 1]; | 156 | static char **myargv = new char *[myargc + 1]; |
157 | for ( int j = 0; j < myargc; j++ ) { | 157 | for ( int j = 0; j < myargc; j++ ) { |
158 | myargv[j] = new char [strlen(argList.at(j))+1]; | 158 | myargv[j] = new char [strlen(argList.at(j))+1]; |
159 | strcpy( myargv[j], argList.at(j) ); | 159 | strcpy( myargv[j], argList.at(j) ); |
160 | } | 160 | } |
161 | myargv[myargc] = NULL; | 161 | myargv[myargc] = NULL; |
162 | #ifdef _OS_LINUX_ | 162 | #ifdef _OS_LINUX_ |
163 | // Change name of process | 163 | // Change name of process |
164 | setproctitle(myargv[0]); | 164 | setproctitle(myargv[0]); |
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 167 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
168 | app->exit_loop(); | 168 | app->exit_loop(); |
169 | app->initApp( myargc, myargv ); | 169 | app->initApp( myargc, myargv ); |
170 | exec( myargc, myargv ); | 170 | exec( myargc, myargv ); |
171 | } | 171 | } |
172 | 172 | ||
173 | private: | 173 | private: |
174 | QCopChannel *qlChannel; | 174 | QCopChannel *qlChannel; |
175 | }; | 175 | }; |
176 | 176 | ||
177 | int main( int argc, char** argv ) | 177 | int main( int argc, char** argv ) |
178 | { | 178 | { |
179 | app = new QPEApplication( argc, argv ); | 179 | app = new QPEApplication( argc, argv ); |
180 | 180 | ||
181 | loader = new PluginLoader( "application" ); | 181 | loader = new PluginLoader( "application" ); |
182 | 182 | ||
183 | unsetenv( "LD_BIND_NOW" ); | 183 | unsetenv( "LD_BIND_NOW" ); |
184 | 184 | ||
185 | QCString arg0 = argv[0]; | 185 | QCString arg0 = argv[0]; |
186 | int sep = arg0.findRev( '/' ); | 186 | int sep = arg0.findRev( '/' ); |
187 | if ( sep > 0 ) | 187 | if ( sep > 0 ) |
188 | arg0 = arg0.mid( sep+1 ); | 188 | arg0 = arg0.mid( sep+1 ); |
189 | if ( arg0 != "quicklauncher" ) { | 189 | if ( arg0 != "quicklauncher" ) { |
190 | odebug << "QuickLauncher invoked as: " << arg0.data() << "" << oendl; | 190 | odebug << "QuickLauncher invoked as: " << arg0.data() << oendl; |
191 | QuickLauncher::exec( argc, argv ); | 191 | QuickLauncher::exec( argc, argv ); |
192 | } else { | 192 | } else { |
193 | #ifdef _OS_LINUX_ | 193 | #ifdef _OS_LINUX_ |
194 | // Setup to change proc title | 194 | // Setup to change proc title |
195 | int i; | 195 | int i; |
196 | char **envp = environ; | 196 | char **envp = environ; |
197 | /* Move the environment so we can reuse the memory. | 197 | /* Move the environment so we can reuse the memory. |
198 | * (Code borrowed from sendmail.) */ | 198 | * (Code borrowed from sendmail.) */ |
199 | for (i = 0; envp[i] != NULL; i++) | 199 | for (i = 0; envp[i] != NULL; i++) |
200 | continue; | 200 | continue; |
201 | environ = (char **) malloc(sizeof(char *) * (i + 1)); | 201 | environ = (char **) malloc(sizeof(char *) * (i + 1)); |
202 | if (environ == NULL) | 202 | if (environ == NULL) |
203 | return -1; | 203 | return -1; |
204 | for (i = 0; envp[i] != NULL; i++) | 204 | for (i = 0; envp[i] != NULL; i++) |
205 | if ((environ[i] = strdup(envp[i])) == NULL) | 205 | if ((environ[i] = strdup(envp[i])) == NULL) |
206 | return -1; | 206 | return -1; |
207 | environ[i] = NULL; | 207 | environ[i] = NULL; |
208 | 208 | ||
209 | argv0 = argv; | 209 | argv0 = argv; |
210 | if (i > 0) | 210 | if (i > 0) |
211 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; | 211 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; |
212 | else | 212 | else |
213 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; | 213 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; |
214 | #endif | 214 | #endif |
215 | (void)new QuickLauncher(); | 215 | (void)new QuickLauncher(); |
216 | odebug << "QuickLauncher running" << oendl; | 216 | odebug << "QuickLauncher running" << oendl; |
217 | // Pre-load default fonts | 217 | // Pre-load default fonts |
218 | QFontMetrics fm( QApplication::font() ); | 218 | QFontMetrics fm( QApplication::font() ); |
219 | fm.ascent(); // causes font load. | 219 | fm.ascent(); // causes font load. |
220 | QFont f( QApplication::font() ); | 220 | QFont f( QApplication::font() ); |
221 | f.setWeight( QFont::Bold ); | 221 | f.setWeight( QFont::Bold ); |
222 | QFontMetrics fmb( f ); | 222 | QFontMetrics fmb( f ); |
223 | fmb.ascent(); // causes font load. | 223 | fmb.ascent(); // causes font load. |
224 | 224 | ||
225 | // Each of the following force internal structures/internal | 225 | // Each of the following force internal structures/internal |
226 | // initialization to be performed. This may mean allocating | 226 | // initialization to be performed. This may mean allocating |
227 | // memory that is not needed by all applications. | 227 | // memory that is not needed by all applications. |
228 | #if 0 | 228 | #if 0 |
229 | TimeZone::current().isValid(); // popuplate timezone cache | 229 | TimeZone::current().isValid(); // popuplate timezone cache |
230 | TimeString::currentDateFormat(); // create internal structures | 230 | TimeString::currentDateFormat(); // create internal structures |
231 | TimeString::currentAMPM(); | 231 | TimeString::currentAMPM(); |
232 | #endif | 232 | #endif |
233 | Resource::loadIconSet("new"); // do internal init | 233 | Resource::loadIconSet("new"); // do internal init |
234 | 234 | ||
235 | /* make sure libopie gets lined in */ | 235 | /* make sure libopie gets lined in */ |
236 | { | 236 | { |
237 | Opie::Ui::OWait item; | 237 | Opie::Ui::OWait item; |
238 | } | 238 | } |
239 | 239 | ||
240 | // Create a widget to force initialization of title bar images, etc. | 240 | // Create a widget to force initialization of title bar images, etc. |
241 | QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 241 | QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
242 | QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); | 242 | QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); |
243 | w->setGeometry( -100, -100, 10, 10 ); | 243 | w->setGeometry( -100, -100, 10, 10 ); |
244 | w->show(); | 244 | w->show(); |
245 | QTimer::singleShot( 0, w, SLOT(close()) ); | 245 | QTimer::singleShot( 0, w, SLOT(close()) ); |
246 | 246 | ||
247 | app->enter_loop(); | 247 | app->enter_loop(); |
248 | } | 248 | } |
249 | 249 | ||
250 | int rv = app->exec(); | 250 | int rv = app->exec(); |
251 | 251 | ||
252 | if ( mainWindow ) | 252 | if ( mainWindow ) |
253 | delete (QWidget*)mainWindow; | 253 | delete (QWidget*)mainWindow; |
254 | 254 | ||
255 | delete app; | 255 | delete app; |
256 | if ( appIface ) | 256 | if ( appIface ) |
257 | loader->releaseInterface( appIface ); | 257 | loader->releaseInterface( appIface ); |
258 | delete loader; | 258 | delete loader; |
259 | // Neither QLibrary nor my Dropin is a QObject and they don't depend | 259 | // Neither QLibrary nor my Dropin is a QObject and they don't depend |
260 | // on a qApp so we destroy QWidget::destroyMapper() without | 260 | // on a qApp so we destroy QWidget::destroyMapper() without |
261 | // crashing the app | 261 | // crashing the app |
262 | // | 262 | // |
263 | // The problem is there are some 'static' resources not freed | 263 | // The problem is there are some 'static' resources not freed |
264 | // in the apps and on destructing these objects are not available | 264 | // in the apps and on destructing these objects are not available |
265 | // anymore. In future fix up the apps but for now | 265 | // anymore. In future fix up the apps but for now |
266 | // we just skip deletion and hope things go well -zecke | 266 | // we just skip deletion and hope things go well -zecke |
267 | // delete app; | 267 | // delete app; |
268 | // hack instead -zecke | 268 | // hack instead -zecke |
269 | // delete app->pidChannel; | 269 | // delete app->pidChannel; |
270 | // app->pidChannel = 0; | 270 | // app->pidChannel = 0; |
271 | 271 | ||
272 | return rv; | 272 | return rv; |
273 | } | 273 | } |
274 | 274 | ||
275 | #include "main.moc" | 275 | #include "main.moc" |