Skip to content

Commit

Permalink
BUG: Fix crash upon selecting files with DICOM browser import dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesobutler committed Jul 13, 2021
1 parent e485a3f commit ec292b1
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit ec292b1

Please sign in to comment.