Ignore:
Timestamp:
Jan 21, 2018, 11:33:15 PM (6 years ago)
Author:
chronos
Message:
  • Added: Locking of video memory because it is accessed by main thread and also application threads.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Platform/Base/UPlatformBase.pas

    r18 r19  
    9393    (VideoMode.Size.Y <> Mode.Size.Y) or
    9494    (VideoMode.ColorFormat <> Mode.ColorFormat) then begin
    95       VideoMode.Size := Mode.Size;
    96       VideoMode.ColorFormat := Mode.ColorFormat;
    97       ReAllocMem(VideoMemory, VideoMode.GetBytesPerImage);
    98       FillDWord(VideoMemory^, VideoMode.GetBytesPerImage div 4, $ffffff);
     95      Lock.Acquire;
     96      try
     97        if Mode.GetBytesPerImage <> VideoMode.GetBytesPerImage then begin
     98          ReAllocMem(VideoMemory, Mode.GetBytesPerImage);
     99          FillDWord(VideoMemory^, Mode.GetBytesPerImage div 4, $ffffff);
     100        end;
     101        VideoMode.Size := Mode.Size;
     102        VideoMode.ColorFormat := Mode.ColorFormat;
     103      finally
     104        Lock.Release;
     105      end;
    99106      if Assigned(FOnModeChanged) then
    100107        FOnModeChanged(Self);
     
    151158destructor TDeviceVideoBase.Destroy;
    152159begin
    153   VideoMode.Free;
    154160  inherited Destroy;
    155161end;
Note: See TracChangeset for help on using the changeset viewer.