diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-05-08 14:41:32 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-05-08 14:44:04 +0900 |
commit | 7524af262cebd82c0285e0e90add99b1fc7a85d1 (patch) | |
tree | ffc8f12e3fd98be5896cb43b12c39b539d2862e3 | |
parent | 1969a86a14a73363dd2bc1a789f8d673be226243 (diff) | |
download | kcmautostart-7524af262cebd82c0285e0e90add99b1fc7a85d1.tar.gz kcmautostart-7524af262cebd82c0285e0e90add99b1fc7a85d1.zip |
Fixed TCC crash when using non .desktop entries. This resolves bug 2990
and 3105.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | src/autostart.cpp | 136 |
1 files changed, 64 insertions, 72 deletions
diff --git a/src/autostart.cpp b/src/autostart.cpp index 188b3c9..9e68188 100644 --- a/src/autostart.cpp +++ b/src/autostart.cpp @@ -41,80 +41,72 @@ class CDesktopItem : public TDEListViewItem { public: - KService * service; - bool bisDesktop; + KService *mService; KURL fileName; int iStartOn; enum { AutoStart, Shutdown, ENV }; -CDesktopItem( TQString service, int startOn, TQListView *parent ): TDEListViewItem( parent ) { - iStartOn = startOn; - fileName = KURL(service); - if (service.endsWith(".desktop")) { - this->service = new KService(service); - bisDesktop = true; - } -} + CDesktopItem( TQString service, int startOn, TQListView *parent ): TDEListViewItem( parent ), + mService(NULL), iStartOn(startOn), fileName(KURL(service)) + { + if (service.endsWith(".desktop")) { + mService = new KService(service); + } + } -~CDesktopItem() { - if(service) { - delete service; - service = NULL; + ~CDesktopItem() { + if (mService) { + delete mService; + mService = NULL; + } } -} -bool isDesktop() { return bisDesktop; } - -int startOn() { return iStartOn; } - -TQString fStartOn() { - switch (iStartOn) { - case AutoStart: - return i18n("Startup"); - break; - case Shutdown: - return i18n("Shutdown"); - break; - case ENV: - return i18n("ENV"); - break; - default: - return ""; - break; - } -} + TQString fStartOn() { + switch (iStartOn) { + case AutoStart: + return i18n("Startup"); + break; + case Shutdown: + return i18n("Shutdown"); + break; + case ENV: + return i18n("ENV"); + break; + default: + return ""; + break; + } + } -void setStartOn(int start) { - iStartOn = start; - setText(2, fStartOn()); - TQString path; - switch (iStartOn) { - case AutoStart: - path = TDEGlobalSettings::autostartPath()+"/"; - break; - case Shutdown: - path = TDEGlobal::dirs()->localtdedir()+"shutdown/"; - break; - case ENV: - path = TDEGlobal::dirs()->localtdedir()+"env/"; - break; - } - TDEIO::file_move(fileName, KURL( path + fileName.fileName() )); - fileName = path + fileName.fileName(); -} + void setStartOn(int start) { + iStartOn = start; + setText(2, fStartOn()); + TQString path; + switch (iStartOn) { + case AutoStart: + path = TDEGlobalSettings::autostartPath()+"/"; + break; + case Shutdown: + path = TDEGlobal::dirs()->localtdedir()+"shutdown/"; + break; + case ENV: + path = TDEGlobal::dirs()->localtdedir()+"env/"; + break; + } + TDEIO::file_move(fileName, KURL( path + fileName.fileName() )); + fileName = path + fileName.fileName(); + } -void updateService() { - if (bisDesktop) { - if (service) { - delete service; - service = NULL; - } - service = new KService( fileName.path() ); - setText( 0, service->name() ); - setText( 1, service->exec() ); - setText( 2, fStartOn() ); - } -} + void updateService() { + if (mService) { + delete mService; + mService = NULL; + } + mService = new KService( fileName.path() ); + setText( 0, mService->name() ); + setText( 1, mService->exec() ); + setText( 2, fStartOn() ); + } }; //class CDesktopItem @@ -210,8 +202,8 @@ void CAutostart::load() TQFileInfo *fi; while ( (fi = it.current()) != 0 ) { TQString filename = fi->fileName(); - CDesktopItem * item = new CDesktopItem( fi->absFilePath(), x, listCMD ); - if ( ! item->isDesktop() ) { + CDesktopItem *item = new CDesktopItem( fi->absFilePath(), x, listCMD ); + if ( !item->mService ) { if ( fi->isSymLink() ) { TQString link = fi->readLink(); item->setText( 0, filename ); @@ -225,8 +217,8 @@ void CAutostart::load() } } else { - item->setText( 0, item->service->name() ); - item->setText( 1, item->service->exec() ); + item->setText( 0, item->mService->name() ); + item->setText( 1, item->mService->exec() ); item->setText( 2, item->fStartOn() ); } ++it; @@ -282,8 +274,8 @@ void CAutostart::addCMD() { } CDesktopItem * item = new CDesktopItem( TDEGlobalSettings::autostartPath() + service->name() + ".desktop", CDesktopItem::AutoStart, listCMD ); - item->setText( 0, item->service->name() ); - item->setText( 1, item->service->exec() ); + item->setText( 0, item->mService->name() ); + item->setText( 1, item->mService->exec() ); item->setText( 2, item->fStartOn() ); emit changed(true); } @@ -327,7 +319,7 @@ void CAutostart::setStartOn( int index ) { void CAutostart::selectionChanged(TQListViewItem* entry) { cmbStartOn->setEnabled( (entry != 0) ); - cmbStartOn->setCurrentItem( ((CDesktopItem*)entry)->startOn() ); + cmbStartOn->setCurrentItem( ((CDesktopItem*)entry)->iStartOn ); } void CAutostart::defaults(){} |