[Done] PureBasic 6.40 alpha 1 Open Save File

Post bugs related to the IDE here
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

[Done] PureBasic 6.40 alpha 1 Open Save File

Post by ChrisR »

The IDE include in PB 6.40 alpha 1 (windows x64) crashes on Open or Save File
Last edited by ChrisR on Wed Jan 28, 2026 12:42 pm, edited 1 time in total.
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 1 Open Save File

Post by ChrisR »

I don't know if it can helps, but my application compiled with 6.40a1 also crashes on Open(Save)FileRequester, with OnErrorCall, I have:
Error Message: Unknown error code
Source Code File\Line = ProcedureReturn Result (#PB_ProcessPureBasicEvents) in my WinCallback

However, I tried to reproduce it with a simple code using SetWindowCallback() and OpenFileRequester() behind a button, but I cannot reproduce it here!

The rest, generating code with a lot of large string manipulation, seems to work well.
By adding a loop to the code generation to measure speed with a large interface, I go from 9 ms to 7 ms.
Knowing that most concatenations are done using ExString, but a 2 ms gain is always welcome, congrat :)
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 6.40 alpha 1 Open Save File

Post by Fred »

Could you give me the ErrorCode() value you get when using OpenFileRequester() ?
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 1 Open Save File

Post by ChrisR »

Image

Code: Select all

Windows: 11 x64
IceDesign Version: 2.4.2
Source Code File: ObjectTheme.pbi
Source Code Line: 1245   (ProcedureReturn Result (#PB_ProcessPureBasicEvents) in ObjectTheme WinCallback)

Error Code: -529697949
Error Message: Unknown error code
fryquez
Enthusiast
Enthusiast
Posts: 394
Joined: Mon Dec 21, 2015 8:12 pm

Re: PureBasic 6.40 alpha 1 Open Save File

Post by fryquez »

With PB 6.40 you need to fix all strings modified by API or manual character length changes.

Code: Select all

CompilerIf #PB_Compiler_Version >= 640
  
  Procedure ResetStringLength(*s.Character)
    
    Protected *p.Integer = *s -SizeOf(Integer)
    *p\i = 0
    While *s\c
      *p\i + 1
      *s + SizeOf(Character)
    Wend
    
  EndProcedure
  
CompilerElse
  
  Macro ResetStringLength(s)
    ;
  EndMacro
  
CompilerEndIf
In your WinCallback() there you have GetClassName_() call

Code: Select all

Buffer = Space(64)
IF GetClassName_(ParentGadget, @Buffer, 64)
ResetStringLength(@Buffer)
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 1 Open Save File

Post by ChrisR »

Oh! yes, thanks a lot fryquez and glad to see you around my friend :)
Well, I couldn't test it right away, I have lots of other space() and strings modified by API elsewhere to correct too.
But that's the right track, indeed, I didn't think beyond the end of my nose.
And thanks also for the ResetStringLength() macro/procedure.

So, there must be something similar in the IDE as well!
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 6.40 alpha 1 Open Save File

Post by Fred »

Thanks for the error code, should be fixed for the next alpha
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: [Done] PureBasic 6.40 alpha 1 Open Save File

Post by ChrisR »

It looks good for the IDE and my app with PB 6.40 alpha2, thanks :)
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Done] PureBasic 6.40 alpha 1 Open Save File

Post by Fred »

Nice !
User avatar
idle
Always Here
Always Here
Posts: 6188
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [Done] PureBasic 6.40 alpha 1 Open Save File

Post by idle »

most of the windows API functions if not all that set a string length either return the length or set a variable with the length
so you could poke the length without having to parse the string.

Code: Select all

PureBasicPath$ = Space(#MAX_PATH)
len = GetModuleFileName_(GetModuleHandle_(#Null$), @PureBasicPath$, #MAX_PATH)
If Len > 0 
  Debug PeekL(@PureBasicPath$-8)
  PokeI(@PureBasicPath$-8,len) 
  Debug Len(PureBasicPath$)
  Debug PureBasicPath$
EndIf 


Whether this would be safe depends If Fred uses any of the MSB for flags on the length variable but that would limit strings to 1gb on x86 unless the structure on x86 was extended with a quad for length.
I'll wait and see!
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: [Done] PureBasic 6.40 alpha 1 Open Save File

Post by ChrisR »

Yep, -SizeOf(Integer), I'll wait and see too!
See also, ReplaceCharNewLen() here, without API. Without resetting the len in the loop, PeeKS() must then be called after the procedure, with a second loops then.
Any procedures on string with a loop per character that modify the final length will be in the same situation, with the length managed internally in the loop or using PeeKS afterward.
Post Reply