Fixed crash when removing folders.

Simplified code to achieve that, removed a slot from status dia.
This commit is contained in:
Klaas Freitag 2012-03-16 10:39:20 +01:00
parent 16a9a73ea3
commit b7eae107ae
3 changed files with 19 additions and 33 deletions

View File

@ -262,18 +262,21 @@ void Application::slotAddFolder()
_folderMan->restoreEnabledFolders();
}
/*
* the folder is to be removed. The slot is called from a signal emitted by
* the status dialog, which removes the folder from its list by itself.
*/
void Application::slotRemoveFolder( const QString& alias )
{
int ret = QMessageBox::question( 0, tr("Confirm Folder Remove"), tr("Do you really want to remove upload folder <i>%1</i>?").arg(alias),
QMessageBox::Yes|QMessageBox::No );
int ret = QMessageBox::question( 0, tr("Confirm Folder Remove"), tr("Do you really want to remove upload folder <i>%1</i>?").arg(alias),
QMessageBox::Yes|QMessageBox::No );
if( ret == QMessageBox::No ) {
return;
}
if( ret == QMessageBox::No ) {
return;
}
_folderMan->slotRemoveFolder( alias );
_folderMan->slotRemoveFolder( alias );
_statusDialog->slotFolderRemoved( _folderMan->folder(alias) );
}
#ifdef HAVE_FETCH_AND_PUSH

View File

@ -252,24 +252,6 @@ void StatusDialog::slotUpdateFolderState( Folder *folder )
}
}
void StatusDialog::slotFolderRemoved( Folder *folder )
{
QStandardItem *item = 0;
int row = 0;
item = _model->item( row );
while( item ) {
if( item->data( FolderViewDelegate::FolderAliasRole ) == folder->alias() ) {
break;
}
item = _model->item( ++row );
}
if( item ) {
_model->removeRow( row );
}
}
void StatusDialog::folderToModelItem( QStandardItem *item, Folder *f )
{
QIcon icon = _theme->folderIcon( f->backend(), 48 );
@ -289,14 +271,16 @@ void StatusDialog::folderToModelItem( QStandardItem *item, Folder *f )
void StatusDialog::slotRemoveFolder()
{
QModelIndex selected = _folderList->selectionModel()->currentIndex();
if( selected.isValid() ) {
QString alias = _model->data( selected, FolderViewDelegate::FolderAliasRole ).toString();
qDebug() << "Remove Folder alias " << alias;
if( !alias.isEmpty() ) {
emit(removeFolderAlias( alias ));
QModelIndex selected = _folderList->selectionModel()->currentIndex();
if( selected.isValid() ) {
QString alias = _model->data( selected, FolderViewDelegate::FolderAliasRole ).toString();
qDebug() << "Remove Folder alias " << alias;
if( !alias.isEmpty() ) {
// remove from file system through folder man
emit(removeFolderAlias( alias ));
_model->removeRow( selected.row() );
}
}
}
}
void StatusDialog::slotFetchFolder()

View File

@ -89,7 +89,6 @@ public slots:
void slotAddSync();
void slotAddFolder( Folder* );
void slotUpdateFolderState( Folder* );
void slotFolderRemoved( Folder* );
void slotCheckConnection();
protected slots: