Workaround.pbi PB v5.60 (All OS)

Share your advanced PureBasic knowledge/code with the community.
User avatar
mk-soft
Always Here
Always Here
Posts: 6250
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Workaround.pbi PB v5.60 (All OS)

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 6250
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post by mk-soft »

Part two (Reserve)
Last edited by mk-soft on Thu Jun 15, 2017 8:51 am, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

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

Post 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
Last edited by walbus on Thu Jun 15, 2017 8:53 am, edited 1 time in total.
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

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

Post by RSBasic »

Nice title but I don't like workarounds but isn't avoidable.
Image
Image
Post Reply