author | zecke <zecke> | 2004-09-12 20:31:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-12 20:31:20 (UTC) |
commit | b52e2e46ec535a5307276b8fdf1e578aa5d29283 (patch) (unidiff) | |
tree | f30d0fd2faaf89c2bc982e3f8a645645bf74edd8 /core/pim | |
parent | 90aaa298cc69522e88e1f81ade7d5259131b1544 (diff) | |
download | opie-b52e2e46ec535a5307276b8fdf1e578aa5d29283.zip opie-b52e2e46ec535a5307276b8fdf1e578aa5d29283.tar.gz opie-b52e2e46ec535a5307276b8fdf1e578aa5d29283.tar.bz2 |
-Only create configWidgets once per config dialog, properly delete them
-Delete the Widgets before we remove the plugin from our address space
some random clean ups
-rw-r--r-- | core/pim/today/today.cpp | 30 | ||||
-rw-r--r-- | core/pim/today/today.h | 1 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 28 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 4 |
4 files changed, 37 insertions, 26 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index a8c8651..be7cbce 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -27,8 +27,9 @@ | |||
27 | 27 | ||
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qmessagebox.h> | ||
31 | 32 | ||
32 | using namespace Opie::Ui; | 33 | using namespace Opie::Ui; |
33 | using Opie::Core::OPluginItem; | 34 | using Opie::Core::OPluginItem; |
34 | using Opie::Core::OPluginLoader; | 35 | using Opie::Core::OPluginLoader; |
@@ -53,16 +54,14 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
53 | 54 | ||
54 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 55 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
55 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 56 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
56 | 57 | ||
57 | #if defined(Q_WS_QWS) | ||
58 | #if !defined(QT_NO_COP) | 58 | #if !defined(QT_NO_COP) |
59 | 59 | ||
60 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); | 60 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); |
61 | connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 61 | connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
62 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); | 62 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
63 | #endif | 63 | #endif |
64 | #endif | ||
65 | 64 | ||
66 | setOwnerField(); | 65 | setOwnerField(); |
67 | m_big_box = 0L; | 66 | m_big_box = 0L; |
68 | 67 | ||
@@ -83,9 +82,8 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
83 | 82 | ||
84 | init(); | 83 | init(); |
85 | loadPlugins(); | 84 | loadPlugins(); |
86 | initialize(); | 85 | initialize(); |
87 | QPEApplication::showWidget( this ); | ||
88 | } | 86 | } |
89 | 87 | ||
90 | /** | 88 | /** |
91 | * Qcop receive method. | 89 | * Qcop receive method. |
@@ -178,13 +176,26 @@ void Today::loadPlugins() { | |||
178 | 176 | ||
179 | m_pluginLoader = new OPluginLoader( "today", true ); | 177 | m_pluginLoader = new OPluginLoader( "today", true ); |
180 | m_pluginLoader->setAutoDelete( true ); | 178 | m_pluginLoader->setAutoDelete( true ); |
181 | 179 | ||
182 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); | ||
183 | |||
184 | m_manager = new OPluginManager( m_pluginLoader ); | 180 | m_manager = new OPluginManager( m_pluginLoader ); |
185 | m_manager->load(); | 181 | m_manager->load(); |
186 | 182 | ||
183 | /* | ||
184 | * check if loading of Plugins crashed | ||
185 | */ | ||
186 | if( m_pluginLoader->isInSafeMode() ) { | ||
187 | QMessageBox::information(this, tr("Today Error"), | ||
188 | tr("<qt>The plugin '%1' caused Today to crash." | ||
189 | " It could be that the plugin is not properly" | ||
190 | " installed.<br>Today tries to continue loading" | ||
191 | " plugins.</qt>") | ||
192 | .arg( m_manager->crashedPlugin().name())); | ||
193 | } | ||
194 | |||
195 | OPluginItem::List lst = m_pluginLoader->filtered( true ); | ||
196 | |||
197 | |||
187 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 198 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
188 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 199 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
189 | 200 | ||
190 | TodayPlugin plugin; | 201 | TodayPlugin plugin; |
@@ -232,9 +243,9 @@ void Today::startConfig() { | |||
232 | 243 | ||
233 | TodayConfig conf( this, "dialog", true ); | 244 | TodayConfig conf( this, "dialog", true ); |
234 | conf.setUpPlugins( m_manager, m_pluginLoader ); | 245 | conf.setUpPlugins( m_manager, m_pluginLoader ); |
235 | 246 | ||
236 | if ( conf.exec() == QDialog::Accepted ) { | 247 | if ( QPEApplication::execDialog(&conf) == QDialog::Accepted ) { |
237 | conf.writeConfig(); | 248 | conf.writeConfig(); |
238 | initialize(); | 249 | initialize(); |
239 | } else { | 250 | } else { |
240 | // since reinitialize is not called in that case , reconnect the signal | 251 | // since reinitialize is not called in that case , reconnect the signal |
@@ -343,12 +354,11 @@ void Today::editCard() { | |||
343 | } | 354 | } |
344 | 355 | ||
345 | 356 | ||
346 | Today::~Today() { | 357 | Today::~Today() { |
347 | if (m_pluginLoader) { | 358 | for(QMap<QString, TodayPlugin>::Iterator it = pluginList.begin(); it != pluginList.end(); ++it ) |
359 | delete it.data().guiBox; | ||
360 | |||
348 | delete m_pluginLoader; | 361 | delete m_pluginLoader; |
349 | } | ||
350 | if (m_manager) { | ||
351 | delete m_manager; | 362 | delete m_manager; |
352 | } | 363 | } |
353 | } | ||
354 | 364 | ||
diff --git a/core/pim/today/today.h b/core/pim/today/today.h index c947ae1..dfc819d 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h | |||
@@ -39,9 +39,8 @@ namespace Opie { | |||
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | class Today : public TodayBase { | 42 | class Today : public TodayBase { |
43 | |||
44 | Q_OBJECT | 43 | Q_OBJECT |
45 | 44 | ||
46 | public: | 45 | public: |
47 | Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 46 | Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index c9823d4..dacce8b 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -95,14 +95,13 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | |||
95 | 95 | ||
96 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); | 96 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); |
97 | previousItem = 0l; | 97 | previousItem = 0l; |
98 | readConfig(); | 98 | readConfig(); |
99 | QPEApplication::showDialog( this ); | ||
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { | 102 | void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { |
104 | 103 | m_configMap.clear(); | |
105 | 104 | ||
106 | m_pluginManager = plugManager; | 105 | m_pluginManager = plugManager; |
107 | m_pluginLoader = plugLoader; | 106 | m_pluginLoader = plugLoader; |
108 | 107 | ||
@@ -112,19 +111,21 @@ void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plu | |||
112 | for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { | 111 | for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { |
113 | lst.prepend((*it)); | 112 | lst.prepend((*it)); |
114 | 113 | ||
115 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 114 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
116 | |||
117 | if ( iface->guiPart()->configWidget(this) != 0l ) { | ||
118 | TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 ); | 115 | TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 ); |
116 | |||
117 | if (!widget ) | ||
118 | continue; | ||
119 | |||
120 | m_configMap.insert( iface, widget ); | ||
119 | TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() | 121 | TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() |
120 | , iface->guiPart()->appName() ); | 122 | , iface->guiPart()->appName() ); |
121 | } | 123 | } |
122 | } | ||
123 | 124 | ||
124 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 125 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) |
125 | pluginManagement( (*it) ); | 126 | pluginManagement( (*it) ); |
126 | } | 127 | |
127 | 128 | ||
128 | TabWidget3->setCurrentTab( tab_2 ); | 129 | TabWidget3->setCurrentTab( tab_2 ); |
129 | } | 130 | } |
130 | 131 | ||
@@ -173,12 +174,12 @@ void TodayConfig::writeConfig() { | |||
173 | 174 | ||
174 | int position = m_appletListView->childCount(); | 175 | int position = m_appletListView->childCount(); |
175 | 176 | ||
176 | QListViewItemIterator list_it( m_appletListView ); | 177 | QListViewItemIterator list_it( m_appletListView ); |
177 | // | 178 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); |
179 | |||
178 | // this makes sure the names get saved in the order selected | 180 | // this makes sure the names get saved in the order selected |
179 | for ( ; list_it.current(); ++list_it ) { | 181 | for ( ; list_it.current(); ++list_it ) { |
180 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); | ||
181 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 182 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
182 | if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { | 183 | if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { |
183 | (*it).setPosition(position--); | 184 | (*it).setPosition(position--); |
184 | m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); | 185 | m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); |
@@ -202,14 +203,13 @@ void TodayConfig::writeConfig() { | |||
202 | 203 | ||
203 | // set autostart settings | 204 | // set autostart settings |
204 | setAutoStart(); | 205 | setAutoStart(); |
205 | 206 | ||
206 | OPluginItem::List lst = m_pluginManager->managedPlugins(); | 207 | OPluginItem::List managedLst = m_pluginManager->managedPlugins(); |
207 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 208 | for ( OPluginItem::List::Iterator it = managedLst.begin(); it != managedLst.end(); ++it ) { |
208 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 209 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
209 | if ( iface->guiPart()->configWidget(this) != 0l ) { | 210 | if ( m_configMap.contains( iface ) ) |
210 | iface->guiPart()->configWidget(this)->writeConfig(); | 211 | m_configMap[iface]->writeConfig(); |
211 | } | ||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index ab79f31..81120d3 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h | |||
@@ -29,8 +29,10 @@ | |||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QLabel; | 30 | class QLabel; |
31 | class QSpinBox; | 31 | class QSpinBox; |
32 | class QTabWidget; | 32 | class QTabWidget; |
33 | class TodayConfigWidget; | ||
34 | class TodayPluginInterface; | ||
33 | 35 | ||
34 | namespace Opie { | 36 | namespace Opie { |
35 | namespace Core { | 37 | namespace Core { |
36 | class OPluginManager; | 38 | class OPluginManager; |
@@ -39,9 +41,8 @@ namespace Opie { | |||
39 | } | 41 | } |
40 | } | 42 | } |
41 | 43 | ||
42 | class TodayConfig : public QDialog { | 44 | class TodayConfig : public QDialog { |
43 | |||
44 | Q_OBJECT | 45 | Q_OBJECT |
45 | 46 | ||
46 | public: | 47 | public: |
47 | TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); | 48 | TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); |
@@ -63,8 +64,9 @@ private: | |||
63 | void pluginManagement( Opie::Core::OPluginItem plugItem); | 64 | void pluginManagement( Opie::Core::OPluginItem plugItem); |
64 | 65 | ||
65 | QListView* m_appletListView; | 66 | QListView* m_appletListView; |
66 | QMap<QString,QCheckListItem*> m_applets; | 67 | QMap<QString,QCheckListItem*> m_applets; |
68 | QMap<TodayPluginInterface*,TodayConfigWidget*> m_configMap; | ||
67 | 69 | ||
68 | int m_autoStart; | 70 | int m_autoStart; |
69 | int m_autoStartTimer; | 71 | int m_autoStartTimer; |
70 | int m_iconSize; | 72 | int m_iconSize; |