Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in selective sync configuration #10065

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
}

// Only allow removal if the item isn't in "ready" state.
if (classification == FolderStatusModel::RootFolder && _model->folder(index)->isReady() && !_model->folder(index)->isDeployed()) {
if (classification == FolderStatusModel::RootFolder && !_model->data(index, FolderStatusDelegate::IsReady).toBool() && !_model->folder(index)->isDeployed()) {
QMenu *menu = new QMenu(tv);
menu->setAttribute(Qt::WA_DeleteOnClose);
removeFolderAction(menu);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/folderstatusdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class FolderStatusDelegate : public QStyledItemDelegate

AddButton, // 1 = enabled; 2 = disabled
FolderSyncText,

IsReady // boolean
};
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override;
Expand Down
16 changes: 14 additions & 2 deletions src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
return QVariant();
return QVariant(f->path() + x._path);
}
case FolderStatusDelegate::IsReady: {
auto f = x._folder;
return f->isReady();
}
}
}
return QVariant();
Expand Down Expand Up @@ -281,6 +285,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
return progress._overallSyncString;
case FolderStatusDelegate::FolderSyncText:
return tr("Local folder: %1").arg(f->shortGuiLocalPath());
case FolderStatusDelegate::IsReady:
return f->isReady();
}
return QVariant();
}
Expand Down Expand Up @@ -568,8 +574,14 @@ bool FolderStatusModel::canFetchMore(const QModelIndex &parent) const

void FolderStatusModel::fetchMore(const QModelIndex &parent)
{
if (!folder(parent)->isReady()) {
return;
{
const auto isReady = data(parent, FolderStatusDelegate::IsReady);

Q_ASSERT(isReady.isValid());

if (!isReady.toBool()) {
return;
}
}

auto info = infoForIndex(parent);
Expand Down