It is currently Fri Nov 15, 2019 1:40 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Threadsafe -> crash when Alt-Tab
PostPosted: Wed Dec 17, 2008 1:12 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1242
Location: Germany, Glienicke
Hi,

If I were the thread-safe mode for the Exe on, get this code is always an error in the debugger and when I wrote this off then a WIN-error when I use the ALT-TAB to go out screen, wants one could tell me why?

Quote:
[ERROR] FlipBuffers()
[ERROR] Invalid memory access. (read error at address 64)


Code:
InitSprite()
InitSprite3D()
InitKeyboard()
InitMouse()

OpenScreen(1024, 768, 32, "Screen")
 
 CreateSprite(1,64,64, #PB_Sprite_Texture)
 CreateSprite3D(1, 1)
 
Repeat

 FlipBuffers()
 If IsScreenActive()
 
  ClearScreen(0)
 
  Start3D()
   DisplaySprite3D(1,64,64)
  Stop3D()
   
  StartDrawing(ScreenOutput())
   DrawingMode(1)
   DrawText(0,0,"Test", $FFFFFF)
  StopDrawing()
 
  ExamineMouse()

  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape) : End : EndIf

 EndIf


ForEver


My System:

Win XP SP3
PB 4.30 x86


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 17, 2008 1:35 am 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5783
Location: Germany
Isn't this the same as this one?
http://www.purebasic.fr/english/viewtopic.php?t=28676

People reported that as fixed with beta5. Is it still happening ?

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 17, 2008 1:54 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1242
Location: Germany, Glienicke
No, it is not the same.
My code above crashes only when I thread-safe enabled and press Alt-Tab.
Without thread-safe, he runs without any problems.

I have just been discovered that was at the Sprite is, the code can thus be shortened:

Code:
InitSprite()
InitKeyboard()

OpenScreen(1024, 768, 32, "Screen")
 
 CreateSprite(1,64,64)
 
Repeat

 ClearScreen($808080)
  DisplaySprite(1,64,64)
 FlipBuffers()
 
 ExamineKeyboard()

Until KeyboardPushed(#PB_Key_Escape)


Alt-Tab with Thread-Safe --> crash at FlipBuffers, or win-error without Debugger
Alt-Tab without Thread-Safe --> run


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Fri Sep 18, 2009 2:49 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1242
Location: Germany, Glienicke
The problem still exists in 4.4 B3, can anyone confirm

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Fri Sep 18, 2009 5:03 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 24, 2008 12:21 am
Posts: 281
same here

_________________
pb 5.11


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Fri Sep 18, 2009 7:09 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8006
Location: Fort Nelson, BC, Canada
Same here. IsScreenActive() should help imho, but doesn't.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Tue Dec 01, 2009 3:46 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1242
Location: Germany, Glienicke
The problem has changed now, the program no longer crashes, but that I shall return no more into the screen!
And the program freezes!
No Debug-Output, No Error!

And even when the Threadsafe!

Here my Code:
Code:
InitSprite()
InitSprite3D()
InitKeyboard()

ExamineDesktops()
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "Screen")
 
 CreateSprite(1,64,64, #PB_Sprite_Texture)
 CreateSprite3D(1, 1)
 
Repeat

 Delay(10)

 FlipBuffers()
 If IsScreenActive()
 
  ClearScreen(0)
 
  Start3D()
   DisplaySprite3D(1,64,64)
  Stop3D()
 
  StartDrawing(ScreenOutput())
   DrawingMode(1)
   DrawText(0,0,"Test", $FFFFFF)
  StopDrawing()

 EndIf
 
 ExamineKeyboard()
 If KeyboardPushed(#PB_Key_Escape) : End : EndIf

ForEver


What am I doing wrong?

SystemDatas:
WINDOWS XP (SP3), 1,8GHz P4, ATI - RADEON 9700, PB 4.40

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Sat Dec 05, 2009 9:40 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3693
Location: Italy
STARGÅTE wrote:
And the program freezes!


Actually it doesn't freeze, fails to restore the screen mode when switching back to it, but if you press escape the program quit nicely as expected.

Don't know what's wrong with your code, if anything is wrong. I don't have much experience with the directx part of pb, but looking at the docs it's seem to me your code should be ok.

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Tue Dec 08, 2009 7:49 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3693
Location: Italy
Using directx7 as subsystem it works, so it has something to do with the directx9 subsystem I suppose (now enabled by default on 4.40).

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Threadsafe -> crash when Alt-Tab
PostPosted: Fri Aug 16, 2013 2:52 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 24, 2007 3:15 pm
Posts: 728
Location: Germany
Just removed the Sprite3D calles to test if the behavior has
changed with the latest version (v5.20 Beta 10) ... but no :cry:
It does have the same behavior when threadsafe is not active,
the screen will not be restored.

Code:
InitSprite()
InitKeyboard()

ExamineDesktops()
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "Screen")
 
 
Repeat

  Delay(100)
 FlipBuffers()
 If IsScreenActive()
   If ScreenActive = #False
     ScrenActive = #True
     CreateSprite(1,64,64)
   EndIf
   ClearScreen(0)
   Debug "Screen active"
   StartDrawing(SpriteOutput(1))
     Box(0, 0, 64, 64, 0)
     DrawingMode(1)
     DrawText(0,0,"Test", $FFFFFF)
    StopDrawing()
    DisplayTransparentSprite(1,64,64)
 Else
  ScreenActive = #False
 EndIf
 
 ExamineKeyboard()
 If KeyboardPushed(#PB_Key_Escape) : End : EndIf

ForEver


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye