]> git.lyx.org Git - lyx.git/commitdiff
check that GetConsoleTitle succeeded
authorAngus Leeming <leeming@lyx.org>
Fri, 29 Apr 2005 08:42:02 +0000 (08:42 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 29 Apr 2005 08:42:02 +0000 (08:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9887 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/ChangeLog
src/support/os_win32.C

index 1c4d2170661b82a5dd01f23a7509b03f39d5a143..d6bea614ae40562fbe237074d0a4d118553f2ceb 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-29  Angus Leeming  <leeming@lyx.org>
+
+       * os_win32.C (init): Merge changes from Asger's win32_kludge.diff
+       file, primarily checking that GetConsoleTitle succeeded.
+
 2005-04-25  Angus Leeming  <leeming@lyx.org>
 
        * abort.C:
index 711eeb3b94fb176095f1a96120aca3e368f5714d..d62b0f4f3950417089bba5c84d7b923c97577528 100644 (file)
@@ -53,7 +53,7 @@ void os::init(int /* argc */, char * argv[])
         *
         * #if defined (_WIN32)
         * # define WIN32_LEAN_AND_MEAN
-        * # include <stdlib.h>  // for __argc,__argv
+        * # include <stdlib.h>  // for __argc, __argv
         * # include <windows.h> // for WinMain
         * #endif
         *
@@ -63,7 +63,7 @@ void os::init(int /* argc */, char * argv[])
         * #if defined (_WIN32)
         * int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
         * {
-        *     return mymain(__argc, __argv);
+        *     return mymain(__argc, __argv);
         * }
         * #endif
         *
@@ -89,12 +89,15 @@ void os::init(int /* argc */, char * argv[])
        // Close the console when run (probably)
        // not run from command prompt
        char WindowTitle[1024];
-       HWND hwndFound;
-       GetConsoleTitle(WindowTitle,1024);
+       if (GetConsoleTitle(WindowTitle, sizeof(WindowTitle)) == 0) {
+               // Could not get the title, so we just leave things as they are
+               return;
+       }
+
        if ((strcmp(WindowTitle, argv[0]) == 0) ||
-               (strcmp(WindowTitle,"LyX") == 0)) {
+               (strcmp(WindowTitle, "LyX") == 0)) {
                // format a "unique" newWindowTitle
-               wsprintf(WindowTitle,"%d/%d",
+               wsprintf(WindowTitle, "%d/%d",
                        GetTickCount(),
                        GetCurrentProcessId());
                // change current window title
@@ -102,9 +105,9 @@ void os::init(int /* argc */, char * argv[])
                // ensure window title has been updated
                Sleep(40);
                // look for newWindowTitle
-               hwndFound=FindWindow(NULL, WindowTitle);
+               HWND const hwndFound = FindWindow(NULL, WindowTitle);
                // If found, hide it
-               if ( hwndFound != NULL)
+               if (hwndFound != NULL)
                        ShowWindow( hwndFound, SW_HIDE);
        }
 }