CnPack Forum


 
Subject: "Small" issue to report
cata
新警察
Rank: 1



UID 6464
Digest Posts 0
Credits 23
Posts 12
点点分 23
Reading Access 10
Registered 2007-3-2
Status Offline
Post at 2008-1-6 02:42  Profile | Blog | P.M. 
"Small" issue to report

Last days an annoying error was shown every time I close BDS 2006 (with CnWizards_0.8.2.356:
Exception error at ..... in module hhctrl.ocx.

After I played a little I found that error appears only if cnwizard is loaded. My problem was to find the error point (pretty hard).

Stepping over my digging researches, the problem is in this function:

function UnLoadHtmlHelp: Boolean;
begin
  Result := True;
  if HtmlHelpLoaded then
  begin
    if Assigned(HtmlHelp) then HtmlHelp(0, nil, HH_CLOSE_ALL, 0);
    Result := FreeLibrary(HtmlHelpLib);
    HtmlHelpLib := 0;
    @HtmlHelpA := nil;
    @HtmlHelpW := nil;
    @HtmlHelp := nil;
  end;
end;

and, more specific, in HtmlHelp(0, nil, HH_CLOSE_ALL, 0).

Seems is an known issue which is not solved by Microsoft.

see this link: http://www.helpware.net/FAR/far_faq.htmin section: HH_CLOSE_ALL Bug and HH_INITIALIZE

copy/paste the text:


  Problem:
    Marcel van Brakel has uncovered a real problem with HH_CLOSE_ALL. When you   call HH_CLOSE_ALL on shut down, the HH API creates another thread   and sometimes does not return until after you have performed UnLoadLibrary(hhctrl.ocx).   In this case the HH_CLOSE_ALL thread returns to nothing and causes an access   violation.
  Discussion:
  Ralph Walden (x-Microsoft) describes the problem:
    The switch to a background thread was done after I left (the MS help team)    in order to solve a problem with Visual Studio. I knew they should have fixed   Visual Studio instead of "fixing" HTML Help (which wasn't broken). I've never   actually tried it, but along with that change was a hack that allowed you to   call the API in a way that it would create an interface, and then you'd call   the API again to release that interface. You start off with HH_INITIALIZE and   end with HH_UNINITIALIZE. Another alternative would be to set the   HH_GPROPID_SINGLETHREAD property to TRUE -- that might get HTML Help back onto   the parent's thread.
  Fix:
   
  • As described by Ralph above, you can try using the     HH_INITIALIZE, HH_UNINITIALIZE commands. These are documented in the HH     Workshop online help.
  • Call HH_CLOSE_ALL earlier. Get more space between the HH_CLOSE_ALL and     your call to UnloadLibrary. In VB and Delphi you would perform the call on     the Form QueryUnload _not_ on the Form Close or Destroy.
  • Marcel van Brakel seemed to fix it by calling     Sleep(0); immediately after the call to HH_CLOSE_ALL. Again providing more     time for the rogue thread to return.
  More Tips:
  Here is an alternative to using HH_CLOSE_ALL. What I do with my   applications is keep the handle of the HH Windows when making a help call:  _HHwinHwnd := htmlhelp(...) and on shutdown call:                
if IsWindow(_HHwinHwnd) then
   SendMessage( _HHwinHwnd, wm_close, 0, 0 );
This is 10 times faster code, and eliminates the   need for HH_CLOSE_ALL completely.
  Also, as programming wizard Roland Mechling points   out, don't blindly call HH_CLOSE_ALL on shutdown. If a user does not have HTML   Help installed then this call will crash your application.   Here is safer code. Notice we are checking if HH is installed before calling   HtmlHelp();                
procedure HHCloseAll;
begin
     If @HH.HtmlHelp <> Nil then  //HH API is available
     begin
           HH.HtmlHelp(0, nil, HH_CLOSE_ALL, 0);
           Sleep(0);
     end;
end;



Also a Borland bug report: http://qc.borland.com/wc/qcmain.aspx?d=48983


I know that is not a cnWizard bug but maybe someone knows a better workaround and can change UnLoadHtmlHelp function.
I tried Sleep(0) but seems doesn't help.

I'll come back with more info.

[ Last edited by  cata at 2008-1-6 04:01 ]
Top
cata
新警察
Rank: 1



UID 6464
Digest Posts 0
Credits 23
Posts 12
点点分 23
Reading Access 10
Registered 2007-3-2
Status Offline
Post at 2008-1-6 03:55  Profile | Blog | P.M. 
Ripped from group discussion:


I have moved the LoadLibrary() from DllMain() to separate initialization
function and that solved the problem.

M.?.

"Miroslav ?ulc" <miroslav.s...@startnet.cz> pí?e v diskusním p?íspìvku
news:3ae99c78@news.cvut.cz...

> Hi Rob,

> I have went through DLLs code and I have realized that I use LoadLibrary()
> in DllMain(). MSDN documentation for DllMain() says that it could be
source
> of strange errors. Now I am moving the LoadLibrary() functions to a
separate
> initialization functions. Then I will see if this is the cause.


This could be the problem because LoadLibrary(PChar(HHOCXPath)) is done in unit initialization of HtmlHlp.pas which is in uses clause of CnMsdnWizard-> uses of CnWizards_D10.dpr, means DllEntryPoint of CnWizards_D10.dll.
So, in fact, is the problem described above.

I'll try to move it to see the effect.

What is strange is that I can't associate the appearance of this problem with an install of specific software/components.

[ Last edited by  cata at 2008-1-6 04:02 ]
Top
cata
新警察
Rank: 1



UID 6464
Digest Posts 0
Credits 23
Posts 12
点点分 23
Reading Access 10
Registered 2007-3-2
Status Offline
Post at 2008-1-6 04:57  Profile | Blog | P.M. 
The fastest solution was to disable MSDN wizard. I didn't used, anyway.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2008-1-7 10:05  Profile | Blog | P.M. 
For a user, if he does not need MSDN Wizard, he can disable it.
But if he need it, what's the simple way to resolve it? Add a Sleep(0); after the call to HH_CLOSE_ALL seems simplest.
Top
cata
新警察
Rank: 1



UID 6464
Digest Posts 0
Credits 23
Posts 12
点点分 23
Reading Access 10
Registered 2007-3-2
Status Offline
Post at 2008-1-8 19:28  Profile | Blog | P.M. 


QUOTE:
Originally posted by Passion at 2008-1-7 10:05
For a user, if he does not need MSDN Wizard, he can disable it.
But if he need it, what's the simple way to resolve it? Add a Sleep(0); after the call to HH_CLOSE_ALL seems simplest.

Agree, but maybe is better to include it in next release.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2008-1-8 20:37  Profile | Blog | P.M. 
Yes. we've add this line into our 0.8.2.361 nighly build verison.

If you can, please download and test it for us?

http://www.cnpack.org/downbuilds.php
Top
cata
新警察
Rank: 1



UID 6464
Digest Posts 0
Credits 23
Posts 12
点点分 23
Reading Access 10
Registered 2007-3-2
Status Offline
Post at 2008-1-10 14:15  Profile | Blog | P.M. 


QUOTE:
Originally posted by Passion at 2008-1-8 20:37
Yes. we've add this line into our 0.8.2.361 nighly build verison.

If you can, please download and test it for us?

http://www.cnpack.org/downbuilds.php

Ok. I'll try it.

Are available the sources for nigthly builds somewhere?
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2008-1-10 16:09  Profile | Blog | P.M. 
Yes. It's in our CVS.

You can get CnPack and CnWizards latest source code from this CVS repository:

CVSROOT:
:pserver:anoncvs@www.cnpack.org:/var/cvshome/cnpack

Password:
anoncvs

Module Name:

cnpack
cnwizards
Top
 




All times are GMT++8, the time now is 2024-11-24 06:14

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.016051 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP