author | llornkcor <llornkcor> | 2002-05-06 20:48:13 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-06 20:48:13 (UTC) |
commit | 24259e7b1446f671861b86ee1abb5d8021b98387 (patch) (side-by-side diff) | |
tree | 2bbc06dbc590ba5cc5f5dd0e56025b07c9fa729b | |
parent | d1dd3ae2eb11a9c6e83eaad817a6f84a53d68691 (diff) | |
download | opie-24259e7b1446f671861b86ee1abb5d8021b98387.zip opie-24259e7b1446f671861b86ee1abb5d8021b98387.tar.gz opie-24259e7b1446f671861b86ee1abb5d8021b98387.tar.bz2 |
fix for rmdir crash
-rw-r--r-- | noncore/settings/tabmanager/tabmanager.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index af76251..f54c837 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp @@ -46,33 +46,33 @@ #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" // <-- made this a little more flexible #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" #define NEW_FOLDER "EmptyTab" #define NEW_APPLICATION "NewApp" #define APPLICATION_EXTENSION ".desktop" #define APPLICATION_EXTENSION_LENGTH 8 /** * Constructor. Sets up signals. Performs initial scan of applications * and tabs */ TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false){ rescanFolder(HOME_APP_DIR); // Connect the signals and slots - connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), + connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(editItem(QListViewItem*))); (tabList->header())->hide(); connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); } /** * If anything in the tab's have been changed then update the system or alert * the user. */ TabManager::~TabManager(){ if(changed){ //QMessageBox::critical(this, tr("Message"), tr("Please restart Qtopia to see all new changes."),tr("Ok") ); //filename = fn; QCopEnvelope e("QPE/System", "linkChanged(QString)"); //e << description << filename << mimetype; @@ -192,62 +192,65 @@ void TabManager::newApplication(){ changed = true; } /** * Remove the item. * Check if we can * Prompt user * Delete physical file (Dir, remove .dir, then dir. File, remove file) * Remove from installer if need too. */ void TabManager::removeItem(){ // Make sure we can delete QListViewItem *item = tabList->currentItem(); if(!item) return; if(item->childCount() > 0){ - QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), + QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); return; } // Prompt. int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); if (answer) return; bool removeSuccessfull = true; QString location = itemList[item]; // Remove file (.directory in a Directory case) if(!QFile::remove(location)) removeSuccessfull = false; // Remove directory if(item->parent() == NULL){ // Remove .directory file string location = location.mid(0,location.length()-10); QDir dir; if(!dir.rmdir(location)) removeSuccessfull = false; + else + removeSuccessfull = true; + } // If removing failed. if(!removeSuccessfull){ qDebug((QString("removeItem: ") + location).latin1()); - QMessageBox::critical(this, tr("Message"), tr("Can't remove."), + QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); return; } // Remove from the installer so it wont fail. // Don't need to do this sense the current install uses rm -f so no error // Remove from the gui list. itemList.remove(item); if(item->parent()) item->parent()->takeItem(item); delete item; // We have changed something. changed = true; } @@ -357,33 +360,33 @@ void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ return; // Get the new folder, new file name, QString newFolder = itemList[newGroup]; newFolder = newFolder.mid(0,newFolder.length()-11); int slash = newFolder.findRev('/', -1); QString folderName = newFolder.mid(slash+1, newFolder.length()); QString desktopFile = itemList[item]; slash = desktopFile.findRev('/', -1); desktopFile = desktopFile.mid(slash, desktopFile.length()); newFolder = newFolder + desktopFile; // Move file QDir r; if(!r.rename(itemList[item], newFolder)){ - QMessageBox::critical(this, tr("Message"), tr("Can't move application."), + QMessageBox::critical(this, tr("Message"), tr("Can't move application."), tr("Ok") ); return; } //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); //qDebug((QString("moveApplication: ") + newFolder).latin1()); // Move in the gui item->parent()->takeItem(item); newGroup->insertItem(item); newGroup->setOpen(true); // Move file in the installer QString installedAppFile; if(findInstalledApplication(desktopFile, installedAppFile)) swapInstalledLocation(installedAppFile, desktopFile, newFolder); else |