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

BUG: Fix crash upon selecting files with DICOM browser import dialog #981

Merged
merged 1 commit into from
Jul 14, 2021
Merged
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
20 changes: 20 additions & 0 deletions Libs/Widgets/ctkFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ QPushButton* ctkFileDialogPrivate::acceptButton()const
QListView* ctkFileDialogPrivate::listView()const
{
Q_Q(const ctkFileDialog);
if (this->UsingNativeDialog)
{
return NULL; // Native dialog does not support modifying or getting widget elements.
}
QListView* listView= q->findChild<QListView*>("listView");
Q_ASSERT(listView);
return listView;
Expand All @@ -107,6 +111,10 @@ QListView* ctkFileDialogPrivate::listView()const
QTreeView* ctkFileDialogPrivate::treeView()const
{
Q_Q(const ctkFileDialog);
if (this->UsingNativeDialog)
{
return NULL; // Native dialog does not support modifying or getting widget elements.
}
QTreeView* treeView = q->findChild<QTreeView*>();
Q_ASSERT(treeView);
return treeView;
Expand Down Expand Up @@ -221,6 +229,10 @@ QAbstractItemView::SelectionMode ctkFileDialog::selectionMode() const
void ctkFileDialog::clearSelection()
{
Q_D(ctkFileDialog);
if (d->UsingNativeDialog)
{
return; // Native dialog does not support modifying or getting widget elements.
}
foreach(QAbstractItemView* view, QList<QAbstractItemView*>()
<< d->listView()
<< d->treeView()
Expand All @@ -234,6 +246,10 @@ void ctkFileDialog::clearSelection()
void ctkFileDialog::setAcceptButtonEnable(bool enable)
{
Q_D(ctkFileDialog);
if (d->UsingNativeDialog)
{
return; // Native dialog does not support modifying or getting widget elements.
}
d->AcceptButtonEnable = enable;
d->IgnoreEvent = true;
d->acceptButton()->setEnabled(d->AcceptButtonEnable && d->AcceptButtonState);
Expand All @@ -244,6 +260,10 @@ void ctkFileDialog::setAcceptButtonEnable(bool enable)
bool ctkFileDialog::eventFilter(QObject *obj, QEvent *event)
{
Q_D(ctkFileDialog);
if (d->UsingNativeDialog)
{
return true; // Native dialog does not support modifying or getting widget elements.
}
QPushButton* button = d->acceptButton();
QDialogButtonBox* dialogButtonBox = qobject_cast<QDialogButtonBox*>(obj);
if (obj == button && event->type() == QEvent::EnabledChange &&
Expand Down