freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][master] [graph/win32] Improve error handl


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] [graph/win32] Improve error handling.
Date: Thu, 02 Feb 2023 15:32:36 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • e08dfe9a
    by Alexei Podtelezhnikov at 2023-02-02T10:24:23-05:00
    [graph/win32] Improve error handling.
    
    * graph/win32/grwin32.c (gr_win32_surface_resize): Change return type.
    (gr_win32_surface_init): Ditto and handle failure gracefully.
    

1 changed file:

Changes:

  • graph/win32/grwin32.c
    ... ... @@ -286,7 +286,7 @@ gr_win32_surface_set_icon( grWin32Surface* surface,
    286 286
      */
    
    287 287
     
    
    288 288
     
    
    289
    -static grWin32Surface*
    
    289
    +static int
    
    290 290
     gr_win32_surface_resize( grWin32Surface*  surface,
    
    291 291
                              int              width,
    
    292 292
                              int              height )
    
    ... ... @@ -327,7 +327,7 @@ gr_win32_surface_resize( grWin32Surface* surface,
    327 327
       surface->bmiHeader.biWidth  = width;
    
    328 328
       surface->bmiHeader.biHeight = -height;
    
    329 329
     
    
    330
    -  return surface;
    
    330
    +  return 1;
    
    331 331
     }
    
    332 332
     
    
    333 333
     static void
    
    ... ... @@ -426,7 +426,7 @@ DWORD WINAPI Window_ThreadProc( LPVOID lpParameter )
    426 426
     }
    
    427 427
     
    
    428 428
     
    
    429
    -static grWin32Surface*
    
    429
    +static int
    
    430 430
     gr_win32_surface_init( grWin32Surface*  surface,
    
    431 431
                            grBitmap*        bitmap )
    
    432 432
     {
    
    ... ... @@ -466,9 +466,6 @@ gr_win32_surface_init( grWin32Surface* surface,
    466 466
         surface->root.bitmap.grays = bitmap->grays;
    
    467 467
       }
    
    468 468
     
    
    469
    -  if ( !gr_win32_surface_resize( surface, bitmap->width, bitmap->rows ) )
    
    470
    -    return 0;
    
    471
    -
    
    472 469
       surface->bmiHeader.biSize   = sizeof( BITMAPINFOHEADER );
    
    473 470
       surface->bmiHeader.biPlanes = 1;
    
    474 471
     
    
    ... ... @@ -533,6 +530,10 @@ gr_win32_surface_init( grWin32Surface* surface,
    533 530
         return 0;         /* Unknown mode */
    
    534 531
       }
    
    535 532
     
    
    533
    +  /* allocate buffers */
    
    534
    +  if ( !gr_win32_surface_resize( surface, bitmap->width, bitmap->rows ) )
    
    535
    +    goto Fail;
    
    536
    +
    
    536 537
       /* set up the main message queue and spin off the window thread */
    
    537 538
       PeekMessage( &msg, (HWND)-1, WM_USER, WM_USER, PM_NOREMOVE );
    
    538 539
       surface->host = GetCurrentThreadId();
    
    ... ... @@ -542,7 +543,7 @@ gr_win32_surface_init( grWin32Surface* surface,
    542 543
       /* listen if window is created */
    
    543 544
       if ( GetMessage ( &msg, (HWND)-1, WM_STATUS, WM_STATUS ) < 0 ||
    
    544 545
            !msg.wParam )
    
    545
    -    return 0;
    
    546
    +    goto Fail;
    
    546 547
     
    
    547 548
       /* wrap up */
    
    548 549
       surface->root.done         = (grDoneSurfaceFunc) gr_win32_surface_done;
    
    ... ... @@ -555,7 +556,11 @@ gr_win32_surface_init( grWin32Surface* surface,
    555 556
             surface->root.bitmap.width, surface->root.bitmap.rows,
    
    556 557
             surface->bmiHeader.biBitCount ));
    
    557 558
     
    
    558
    -  return surface;
    
    559
    +  return 1;
    
    560
    +
    
    561
    +Fail:
    
    562
    +  gr_win32_surface_done( surface );
    
    563
    +  return 0;
    
    559 564
     }
    
    560 565
     
    
    561 566
     
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]