This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/CFT] Fix setup.exe COM initialisation problem.


[  I've got a few patches in the pipeline that I'll be able to send upstream
shortly.  This one needs some thorough testing, so I'm throwing it over the
wall early to give some advance notice and ask for help.  ]

  This fixes the "CoCreateInstance failed with error XXX, Setup will not be
able to create Cygwin Icons in the Start Menu or on the Desktop" problem on
win2k (and maybe earlier?).  I don't think the choice of threading model
matters much to setup.exe; we only use COM for shell functions and common
control dialogs, none of which we're doing in a parallelized or multi-threaded
fashion, so the serialisation between threads within setup.exe implied by
sending requests through an apartment shouldn't cause any noticeable slow
down; this stuff is all happening in a user-interaction-driven fashion anyway.

  However because of the scary comment about win7, I think this must be a
slightly hairy and not necessarily entirely backward-compatible area.  I've
tested it on XP and 2k; can anyone help out by checking it on any of
NT/2k3/Vista/2k8/W7 for me?  I just moved my desktop icons and start folder
menu out of the way, clicked through it in "install from local package dir"
and "keep" mode, and verified in windows explorer that it had created the new
shortcuts correctly, I think that's sufficient.

setup/ChangeLog:

	* main.cc (main_display): Use apartment- rather than multi-
	threaded COM threading model in CoInitialiseEx call.

Index: main.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/main.cc,v
retrieving revision 2.57
diff -p -u -r2.57 main.cc
--- main.cc	3 Oct 2009 10:25:37 -0000	2.57
+++ main.cc	23 Oct 2009 19:38:22 -0000
@@ -160,7 +160,7 @@ main_display ()
   // Windows 7 fails to create the ShellLink instance if this is
   // done later, in the thread which actually creates the shortcuts.
   extern IShellLink *sl;
-  CoInitializeEx (NULL, COINIT_MULTITHREADED);
+  CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
   HRESULT res = CoCreateInstance (&CLSID_ShellLink, NULL,
 				  CLSCTX_INPROC_SERVER, &IID_IShellLink,
 				  (LPVOID *) & sl);

    cheers,
      DaveK


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]