wxProgressDialog doesn't close
wxProgressDialog doesn't close
Hi everyone,
Is there some reason for wxProgressDialog doesn't close after it is been updates to his maximum value?
I have some strange behavior occurring sometimes (it is not a permanent issue). I do some calculations from values readed from a file in a multi thread process, and when a thread ends based on a wxThreadEvent handler it increments a variable and updates the wxProgressDialog.
In the text of the progress dialog appears the current stage of the calculation and it's maximum. As you can see in the image all calculation are done and the wxProgressDialog has been updated, but it won't destroy itself and because it is modal the app doesn't exit of that state.
What can be wrong?
Thanks in advance.
Is there some reason for wxProgressDialog doesn't close after it is been updates to his maximum value?
I have some strange behavior occurring sometimes (it is not a permanent issue). I do some calculations from values readed from a file in a multi thread process, and when a thread ends based on a wxThreadEvent handler it increments a variable and updates the wxProgressDialog.
In the text of the progress dialog appears the current stage of the calculation and it's maximum. As you can see in the image all calculation are done and the wxProgressDialog has been updated, but it won't destroy itself and because it is modal the app doesn't exit of that state.
What can be wrong?
Thanks in advance.
Re: wxProgressDialog doesn't close
Hi,
Can you reproduce it in the dialogs sample?
Thank you.
Can you reproduce it in the dialogs sample?
Thank you.
Re: wxProgressDialog doesn't close
And show some code. The wxProgressDialog should close when it goes out of scope anyway. Did you create it on the stack?
Use the source, Luke!
Re: wxProgressDialog doesn't close
No it is on the heap Could this be the problem?
My event handler that updates de progress bar:
My event handler that updates de progress bar:
Code: Select all
void MyFrame::IncrementaProgressBar()
{
m_passosProgressBarFeitos++;
m_progressCalculoAcumulados->Update(m_passosProgressBarFeitos,
wxT("Por favor espere enquanto . \nFaltam processar ") + wxT(" (") + wxString::Format(wxT("%i"), (unsigned int) m_passosProgressBarFeitos) + wxT("/") + wxString::Format(wxT("%i"), (unsigned int) m_progressCalculoAcumulados->GetRange()) + wxT(")")
);
m_progressCalculoAcumulados->Fit();
}
Re: wxProgressDialog doesn't close
Hi
Dialogs are not meant to be created on the heap.
Try to create it on stack...
Thank you.
Dialogs are not meant to be created on the heap.
Try to create it on stack...
Thank you.
Re: wxProgressDialog doesn't close
But creating the dialog on the heap can cause behaviors like this that I'm facing?
Because most of the times the progress dialog closes itself without issues.
Thanks,
Because most of the times the progress dialog closes itself without issues.
Thanks,
Re: wxProgressDialog doesn't close
Hi,
lease re-read my previous reply carefully, then change your code accordingly.
Keep in mind - this is not specific to progress dialogs. All dialogs needs to be made on stack.
Let us know if it fixes it.
Thank you.
lease re-read my previous reply carefully, then change your code accordingly.
Keep in mind - this is not specific to progress dialogs. All dialogs needs to be made on stack.
Let us know if it fixes it.
Thank you.
Re: wxProgressDialog doesn't close
If this is a rule why in thread sample the progressBar is buit in the heap?Hi,
lease re-read my previous reply carefully, then change your code accordingly.
Keep in mind - this is not specific to progress dialogs. All dialogs needs to be made on stack.
Code: Select all
m_dlgProgress = new wxProgressDialog
(
wxT("Progress dialog"),
wxT("Wait until the thread terminates or press [Cancel]"),
100,
this,
wxPD_CAN_ABORT |
wxPD_APP_MODAL |
wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME
);
It only happens in Windows executables. I've never noticed this behavior in Linux.
Re: wxProgressDialog doesn't close
Creating dialogs on the stack is not a rule, but it makes your life much easier. If the progressdialog doesn't close automatically, you can either try to hunt the reason down, or just close/destroy it yourself (which is what i would do).
Use the source, Luke!
Re: wxProgressDialog doesn't close
Thank you for your suggestion Doublemax.
I will follow it and I will quit using the wxPD_AUTO_HIDE style and I'll destroy the progressBar based on the steps done.
I will follow it and I will quit using the wxPD_AUTO_HIDE style and I'll destroy the progressBar based on the steps done.
Re: wxProgressDialog doesn't close
Hi,
If you will make the dialog on the stack - you will not need to destroy it - it will be done automatically, when it goes out of scope.
Thank you.
If you will make the dialog on the stack - you will not need to destroy it - it will be done automatically, when it goes out of scope.
Thank you.
Re: wxProgressDialog doesn't close
Thanks OneeYeman, but it is easier to do it on the heap because I have several threads doing the work and communicating via events when the work is done, and I cannot be stuck within the method who create de progress bar.