Opened 6 years ago

Last modified 6 years ago

#4658 closed defect

wxDialog::ShowModal fails if dialog is already open

Reported by: hwiesmann Owned by: csomor
Priority: normal Milestone:
Component: wxOSX-Carbon Version:
Keywords: Cc: hwiesmann, csomor
Blocked By: Blocking:
Patch: no

Description

The following code snippet does not work (taken from wxProgressDialog):

wxDialog dialog(....);

dialog.Show();
...
dialog.ShowModal();

Unfortunately, this code fails but it is the recommended way to switch a dialog to a modal dialog because wxDialog::SetModal(bool) is marked as depreciated.

The reason is that inside wxDialog::ShowModal() wxDialog::Show(true) is called and that this one returns false if the dialog is already shown.

Replacing

Show(true);

by

if (this->IsShown())

this->DoShowModal();

else

Show(true);

in wxDialog::ShowModal() should fix the problem.

Hartwig

Change History (2)

comment:1 Changed 6 years ago by vadz

Switching a modeless dialog to modal isn't supported. It probably should assert instead of silently doing nothing but in any case, if you need a modal dialog you really must call ShowModal() from the start.

comment:2 Changed 6 years ago by vadz

  • Cc vadz removed

I was wrong to close this bug as this behaviour must be supported as our own wxProgressDialog uses it (see #4664). I've applied the suggested patch now as part of r54328, thanks.

Note: See TracTickets for help on using tickets.