code is simple
procedure that downloads file http asynchronous to disk
it shows progress in bar and when download is finished it close window
i am using finishhttp on http success and aborted before closing window
what can be reason? tried 5.43 and 5.44b4 32 bit on win10 64bit
compiled exe doesn't crush. i have error in with IDE compile/run example:
[12:06:49] [ERROR] Invalid memory access. (read error at address 4294967295)
invalid memory access on closewindow (not every time) ?
invalid memory access on closewindow (not every time) ?
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: invalid memory access on closewindow (not every time) ?
Are you using with threads without enabling the thread safety compiler option?
Re: invalid memory access on closewindow (not every time) ?
no threads. code is in procedure.Mistrel wrote:Are you using with threads without enabling the thread safety compiler option?
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: invalid memory access on closewindow (not every time) ?
how do you expect anyone to help you, without providing any code? there could be a billion reasons for an invalid memory access.
c ya,
nco2k
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: invalid memory access on closewindow (not every time) ?
nco2k wrote:how do you expect anyone to help you, without providing any code? there could be a billion reasons for an invalid memory access.
c ya,
nco2k
Code: Select all
Procedure.q ReceiveHTTPFile_(p_url.s,p_file.s)
p_download.q=0
p_width=512
p_height=30
p_progress=0
p_f.f=0
p_size.q=0
p_window=0
If p_size<=0
Header$ = GetHTTPHeader(p_url)
Index=0
Repeat
Index+1
Line$ = LTrim(StringField(Header$, Index, #LF$))
If Left(LCase(Line$),Len("Content-Length:"))="content-length:"
p_size=Val(Mid(Line$,Len("Content-Length:")+1))
EndIf
Until Line$ = ""
EndIf
p_kb=p_size/1024
p_window=OpenWindow(#PB_Any,10,10,p_width,p_height,"",#PB_Window_ScreenCentered)
ProgressBarGadget(1,1,1,p_width,p_height,1,p_width,#PB_ProgressBar_Smooth)
SetActiveWindow(p_window)
p_ms.q=ElapsedMilliseconds()-1
p_ms2.q=ElapsedMilliseconds()
p_download=ReceiveHTTPFile(p_url,p_file,#PB_HTTP_Asynchronous)
Repeat
p_progress=HTTPProgress(p_download)
Select p_progress
Case #PB_Http_Success
FinishHTTP(p_download)
p_download=FileSize(p_file)
Break
Case #PB_Http_Failed
p_download=0
Break
Case #PB_Http_Aborted
FinishHTTP(p_download)
p_download=0
Break
Default
p_f=p_progress/p_size*p_width
SetGadgetState(1,p_f)
p_f=(p_progress/1024)/((ElapsedMilliseconds()-p_ms)/1000)
SetWindowTitle(p_window,"Download: "+p_file+" ["+Str(p_kb)+"KB] = "+Str(p_f)+"KB/s") ; bytes: "+Str(p_progress)+"/"+Str(p_size))
If (ElapsedMilliseconds()-p_ms2)>1800
Delay(200)
p_ms2=ElapsedMilliseconds()
; WaitWindowEvent()
EndIf
EndSelect
ForEver
CloseWindow(p_window)
If p_download=0
DeleteFile(p_file)
EndIf
ProcedureReturn p_download
EndProcedure
web_dl.s="http://bios-ict.hr/dl/"
prog_tv.s="TeamViewerQS_hr.exe"
file1.s=""
hr_desktop.s=GetHomeDirectory()+"Radna Površina\"
desktop.s=GetHomeDirectory()+"Desktop\"
If FileSize(desktop)<>-2
desktop=hr_desktop
EndIf
InitNetwork()
file1=prog_tv
If FileSize(file1)=-1 And FileSize(desktop+file1)=-1
If ReceiveHTTPFile_(web_dl+prog_tv,prog_tv)
Delay(500)
EndIf
EndIf
If FileSize(desktop+file1)=-1
If RenameFile(file1,desktop+file1)
Delay(500)
RunProgram(desktop+file1)
EndIf
EndIf
End 0
Code tags added
05.12.2016
RSBasic
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: invalid memory access on closewindow (not every time) ?
You have to process window events. Even if you're not going to act on them, there has to be at least a WindowEvent() in there or it'll eventually crash.
BERESHEIT
Re: invalid memory access on closewindow (not every time) ?
thxnetmaestro wrote:You have to process window events. Even if you're not going to act on them, there has to be at least a WindowEvent() in there or it'll eventually crash.
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: invalid memory access on closewindow (not every time) ?
no luck, crush on closewindow(again not every time):netmaestro wrote:You have to process window events. Even if you're not going to act on them, there has to be at least a WindowEvent() in there or it'll eventually crash.
[08:55:53] [ERROR] Invalid memory access. (read error at address 4294967295)
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: invalid memory access on closewindow (not every time) ?
Try to add this as the first line of your program:
Code: Select all
Global p_window
Re: invalid memory access on closewindow (not every time) ?
i solved it (i hope
only when i add delay before finishhttp error is gone in compile/run and in compiled exe
only when i add delay before finishhttp error is gone in compile/run and in compiled exe
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)