@@ -591,8 +591,8 @@ gen_temp_file(char *outPath)
591591 HANDLE hFile ;
592592 DWORD fileFlags = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY ;
593593
594- if (!GetTempPath2A (MAX_PATH , tempPath )) {
595- logmsg ("GetTempPath2A failed: %d\n" , GetLastError ());
594+ if (!GetTempPathA (MAX_PATH , tempPath )) {
595+ logmsg ("GetTempPathA failed: %d\n" , GetLastError ());
596596 return INVALID_HANDLE_VALUE ;
597597 }
598598
@@ -617,7 +617,7 @@ gen_temp_file(char *outPath)
617617 return hFile ;
618618}
619619
620- void
620+ bool
621621fetch_icon (char * iconUrl , char * outPath )
622622{
623623 HANDLE iconFile ;
@@ -626,27 +626,30 @@ fetch_icon(char *iconUrl, char *outPath)
626626
627627 iconFile = gen_temp_file (outPath );
628628 if (iconFile == INVALID_HANDLE_VALUE ) {
629- return ;
629+ logmsg ("Failed to create temp file for icon: %d\n" , GetLastError ());
630+ return false;
630631 }
631632
633+ logmsg ("Downloading icon to %s\n" , outPath );
632634 doneSignal = CreateEventA (NULL , TRUE, FALSE, NULL );
633635 register_temp_request (iconUrl , iconFile , doneSignal );
634636
635- waitResult = WaitForSingleObject (doneSignal , 5000 );
637+ /* 3-second timeout for icon download so we don't hang if something goes wrong */
638+ waitResult = WaitForSingleObject (doneSignal , 3000 );
636639 CloseHandle (doneSignal );
637- complete_request ();
638640
639641 if (waitResult == WAIT_OBJECT_0 ) {
640642 logmsg ("Icon downloaded successfully.\n" );
641643 CloseHandle (iconFile );
642- return ;
644+ return true ;
643645 } else if (waitResult == WAIT_TIMEOUT ) {
644646 logmsg ("Failed to download icon within timeout.\n" );
645647 } else {
646648 logmsg ("Error while waiting for icon download: %d\n" , GetLastError ());
647649 }
648650
649651 CloseHandle (iconFile );
652+ return false;
650653}
651654
652655int
@@ -721,11 +724,14 @@ main(int argc, char **argv)
721724
722725 srcUrl = args .mainPathOrAddress ;
723726 init_network (srcUrl );
727+ logmsg ("Request pool initialized\n" );
724728
725729 char * iconToUse = NULL ;
726730 if (args .windowIcon ) {
727- fetch_icon (args .windowIcon , iconFile );
728- iconToUse = iconFile ;
731+ logmsg ("Fetching icon: %s\n" , args .windowIcon );
732+ if (fetch_icon (args .windowIcon , iconFile )) {
733+ iconToUse = iconFile ;
734+ }
729735 }
730736
731737 prepare_window (args .windowWidth , args .windowHeight , iconToUse );
0 commit comments