Page 1 of 1

Workaround.pbi PB v5.60 (All OS)

Posted: Wed Jun 14, 2017 7:20 pm
by mk-soft
First part of Workaround

Code: Select all

;-TOP

; Workaround for PB v5.60

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_MacOS
    
    ; -------------------------------------------------------------------------
    
    ; Link http://www.purebasic.fr/english/viewtopic.php?f=24&t=68571
    
    Procedure FixSetGadgetFont(Gadget, FontID)
      SetGadgetFont(Gadget, #PB_Default)
      SetGadgetFont(Gadget, FontID)
    EndProcedure
    
    Macro SetGadgetFont(Gadget, FontID)
      FixSetGadgetFont(Gadget, FontID)
    EndMacro
    
    ; -------------------------------------------------------------------------
    
    ; Link http://www.purebasic.fr/english/viewtopic.php?f=24&t=68494
    
    Procedure FixAddGadgetItem(Gadget, Position, Text.s, Image=0, Flags=0)
      Protected font
      AddGadgetItem(Gadget, Position, Text, Image, Flags)
      If GadgetType(Gadget) = #PB_GadgetType_Editor
        font = GetGadgetFont(Gadget)
        If font
          SetGadgetFont(Gadget, font)
        EndIf
      EndIf
    EndProcedure
    
    Macro AddGadgetItem(Gadget, Position, Text, Image=0, Flags=0)
      FixAddGadgetItem(Gadget, Position, Text, Image, Flags)
    EndMacro
    
    ; -------------------------------------------------------------------------
    
  CompilerCase #PB_OS_Windows
    
    ; -------------------------------------------------------------------------
    ; -------------------------------------------------------------------------
    
  CompilerCase #PB_OS_Linux
    
    ; -------------------------------------------------------------------------
    
    ; Link http://www.purebasic.fr/english/viewtopic.php?f=23&t=68630
    
    Procedure FixWriteData(file, *adress, length) ; Workaround for Linux PB560
      Protected write_data_pointer=Loc(file)
      Protected writen_data=WriteData(file, *adress, length)
      FileSeek(file, write_data_pointer+writen_data)
      ProcedureReturn writen_data
    EndProcedure
    
    Macro WriteData(File, Buffer, Size)
      FixWriteData(File, Buffer, Size)
    EndMacro
    
    ; -------------------------------------------------------------------------
    
CompilerEndSelect

Re: Workaround.pbi PB v5.60 (All OS)

Posted: Wed Jun 14, 2017 7:33 pm
by mk-soft
Part two (Reserve)

Re: Workaround.pbi PB v5.60 (All OS)

Posted: Thu Jun 15, 2017 7:48 am
by walbus
Very Usefull

The WriteData bug can destroy stored data without notice,
this is a highly dangerous bug

I think a 561 will follow soon, also with more Gif functions
I am also surprised, first years of lamenting because of missing Gif, now you can hardly find code for nice Gif handling
Well, maybe comes also to write TIF

Re: Workaround.pbi PB v5.60 (All OS)

Posted: Thu Jun 15, 2017 7:59 am
by RSBasic
Nice title but I don't like workarounds but isn't avoidable.