LiveSpelling problem
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm
LiveSpelling problem
Hi Sergey,
I have a problem with StartLiveSpelling. If I use this function, then when ever I close my MDI editor window it has a chance of crashing the whole application. I figured that if I rem out that line it would never crash. I don't even type anything in, just quickly open and close MDI window with editor in it. Please let me know if there is anything I'm doing wrong.
I have a problem with StartLiveSpelling. If I use this function, then when ever I close my MDI editor window it has a chance of crashing the whole application. I figured that if I rem out that line it would never crash. I don't even type anything in, just quickly open and close MDI window with editor in it. Please let me know if there is anything I'm doing wrong.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm
Hi Sergey,
I fixed my problem by changing RVThread unit.
Here is original code:
And here is my change:
Please let me know if what I did is not apropriate.
I fixed my problem by changing RVThread unit.
Here is original code:
Code: Select all
{------------------------------------------------------------------------------}
{ Waits while finishing processing the current item and closes the thread.
Context: main process (caller) }
procedure TRVWordEnumThread.Finish;
{$IFNDEF RICHVIEWDEF6}
var Msg: TMsg;
{$ENDIF}
begin
if StopWorking=3 then
exit;
StopWorking := 1;
Priority := tpNormal;
while (StopWorking=1) and not Suspended do
{$IFDEF RICHVIEWDEF6}CheckSynchronize;{$ELSE}
if PeekMessage(Msg, 0, $8FFF, $8FFF, PM_REMOVE) then
TranslateMessage(Msg);
{$ENDIF};
if Suspended then
Resume;
Terminate;
end;
Code: Select all
{------------------------------------------------------------------------------}
{ Waits while finishing processing the current item and closes the thread.
Context: main process (caller) }
procedure TRVWordEnumThread.Finish;
{$IFNDEF RICHVIEWDEF6}
var Msg: TMsg;
{$ENDIF}
begin
if StopWorking=3 then
exit;
StopWorking := 1;
Priority := tpNormal;
if Suspended then [color=orange]//I resumed since StopWorking can't change when suspended[/color]
Resume;
while (StopWorking=1) and not Suspended do [color=orange]//Wait till StopWorking turns 2[/color]
{$IFDEF RICHVIEWDEF6}CheckSynchronize;{$ELSE}
if PeekMessage(Msg, 0, $8FFF, $8FFF, PM_REMOVE) then
TranslateMessage(Msg);
{$ENDIF};
Terminate; [color=orange]//Safe to terminate[/color]
while (StopWorking<>3) and not Suspended do [color=orange]//Wait till StopWorking turns 3[/color]
{$IFDEF RICHVIEWDEF6}CheckSynchronize;{$ELSE} [color=orange]//So it won't get out of dll too early [/color]
if PeekMessage(Msg, 0, $8FFF, $8FFF, PM_REMOVE) then
TranslateMessage(Msg);
{$ENDIF};
end;
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hmm. The purpose of this procedure is wating while spellchecking of the next word is complete. If the thread is suspended, there are no reasons to wait for it. The cycle "while (StopWorking=1) and not Suspended do" is not executed if Suspended=True. So my code resumes the suspended thread immediately before calling Terminate.
Probably it would be better to call Terminate before Resume...
Yes, in my code Finish may exit before the thread is terminated, but I do not see a problem here.
Probably it would be better to call Terminate before Resume...
Yes, in my code Finish may exit before the thread is terminated, but I do not see a problem here.
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm
Maybe thats the whole issue - the thread exiting function before it is out of execute. I have special case in using your control. I have it in DLL that is loaded dynamically every time I open MDI and unloaded when I close it. So, the thread being in execute and me unloading DLL might cause the problem. Please, let me know if it makes any sense.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 7
- Joined: Mon Feb 04, 2008 6:51 pm