Re: DoModal isn't reentrant but failure mode could be improved
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 16 Dec 2005 21:32:00 -0500
It is not clear how you can get this situation to come up. The normal way this is done is
CWhateverDialog dlg;
....
dlg.DoModal();
so to call DoModal twice, it means you have not declared the variable as a local variable
in a function. Since there is no advantage to putting it anywhere else (and a severe
disadvantage from what you relate), this looks to me like a violation of good program
design. You should simply not design a program for which this kind of behavior could be
possible. The "unexpected interactions" should have been designed out of existence.
While it is appears to be true that DoModal exhibits pahtological behavior under these
circumstances, it should simply not be possible to have these circumstances ever arise.
Rethink the design.
joe
On Thu, 15 Dec 2005 14:45:41 +0900, "Norman Diamond" <ndiamond@xxxxxxxxxxxxxxxx> wrote:
>It's pretty obvious why a single instance of a CDialog derived class, during
>execution of a call to its DoModal method, can't respond very reasonably to
>another call of its DoModal method. Once we discover that it's being
>attempted, it's obvious why it won't work.
>
>The problem is, when an application accidentally makes that kind of call due
>to unexpected interactions in processing of various Windows Messages, it's
>not pretty obvious that the application has attempted to perform this buggy
>operation.
>
>But it could be made obvious. I think that DoModal() doesn't have to enter
>an infinite loop consuming 100% of the CPU time and making the application
>non-responding. I think that DoModal() could return an error code to anyone
>who calls it while a previous call hasn't returned yet. MFC isn't
>completely dead yet, right? Can this improvement be made?
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: DoModal isn't reentrant but failure mode could be improved
- From: Norman Diamond
- Re: DoModal isn't reentrant but failure mode could be improved
- References:
- DoModal isn't reentrant but failure mode could be improved
- From: Norman Diamond
- DoModal isn't reentrant but failure mode could be improved
- Prev by Date: Re: show time on the dialog and continuously update
- Next by Date: Re: Managing a project as it scales
- Previous by thread: RE: DoModal isn't reentrant but failure mode could be improved
- Next by thread: Re: DoModal isn't reentrant but failure mode could be improved
- Index(es):
Relevant Pages
|
Loading