Please allow OpenWindow inside threads

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Please allow OpenWindow inside threads

Post by PMV »

Danilo wrote:Error on GNU Linux + MacOS X, and on Windows: "Warning: Using OpenWindow()/WaitWindowEvent() within threads is incompatible to GNU Linux and MacOS X!"?
That is what this thread and the other threads are for ...

but
Fred wrote:[...], so with DisableDebugger around the offending calls, all should be working like pre v5.10 versions.
sounds like back to normal :lol: ... still hoping for the future that on windows it will be just a warning :)
And i'm really glad that it is still possible to do it on windows, somehow :D
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Please allow OpenWindow inside threads

Post by netmaestro »

Danilo wrote:on Windows: "Warning: Using OpenWindow()/WaitWindowEvent() within threads is incompatible to GNU Linux and MacOS X!"
If it could be changed to the same warning level you get when you use a deprecated function like CreateGadgetList(), which only warns you without forcing you to change code, I think that would be good. Having to use Disable/Enable Debugger for code that works fine on Windows seems an awkward way to go forward. It is important that the debugger says something to prevent people from unpleasant surprises when porting code to another platform and this would please the most people imho. (or displease the least people, whichever way you see it)
BERESHEIT
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Please allow OpenWindow inside threads

Post by c4s »

netmaestro wrote:If it could be changed to the same warning level you get when you use a deprecated function like CreateGadgetList(), which only warns you without forcing you to change code, I think that would be good.
+1
Although I could live with the slightly clumsy DisableDebugger/EnableDebugger workaround, this would really be the best solution from the (Windows) developer point of view!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Please allow OpenWindow inside threads

Post by skywalk »

This also begs the question?
Why are threads not handled similarly on advanced OS's like GNU Linux and Mac OS X?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Please allow OpenWindow inside threads

Post by MachineCode »

freak wrote:Just keep compiling it with version 4.5 and nothing will change. Nobody forces you to port it to the latest version.
But 4.5 doesn't have any of the bug-fixes of the new 5.10 release. That's the problem.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Please allow OpenWindow inside threads

Post by freak »

MachineCode wrote:
freak wrote:Just keep compiling it with version 4.5 and nothing will change. Nobody forces you to port it to the latest version.
But 4.5 doesn't have any of the bug-fixes of the new 5.10 release. That's the problem.
Unless one of them explicitly stops you from finishing the program, what does it matter? Do you need a bugfix for a command that your program doesn't use?

jaPBe is still compiled with 3.94. It doesn't seem to require the latest 5.10 bugfixes.
quidquid Latine dictum sit altum videtur
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Please allow OpenWindow inside threads

Post by MachineCode »

Bug-fixes are not always just to "fix" something; they can be to add something that we're currently working around with either long-winded code, or other people's libs. For example, I need to use the PureSMTP lib from Gnozal to send emails, because the PureBasic mail lib lacks auth with 4.50. But it's there now in 5.10, which would be great for me to use and ditch Gnozal's lib (no offense to him). But I can't "upgrade" to 5.10 now unless I wrap all my OpenWindow and WindowEvent commands with DisableDebugger (which Fred even said is NOT recommended to do!). A real shame.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Please allow OpenWindow inside threads

Post by c4s »

MachineCode wrote:I can't "upgrade" to 5.10 now unless I wrap all my OpenWindow and WindowEvent commands with DisableDebugger (which Fred even said is NOT recommended to do!).
Yes, he said something like that. But shortly after:
Fred wrote:We re-enabled the previous behaviour on Windows regarding event queue (as it should not impact new code), so with DisableDebugger around the offending calls, all should be working like pre v5.10 versions.
I think the best way of handling this (if it will not be changed from an error to a simple warning message - as requested by many ;-)) is:

Code: Select all

Procedure _OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags=0, ParentID=0)
	Protected Result = 0

	DisableDebugger
	Result = OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentID)
	EnableDebugger  ; Will have no effect if debugger is disabled in compiler settings

	ProcedureReturn Result
EndProcedure

Procedure _WaitWindowEvent(Timeout=#PB_Default)
	Protected Result = 0

	DisableDebugger
	Result = WaitWindowEvent(Timeout)
	EnableDebugger

	ProcedureReturn Result
EndProcedure

Procedure _WindowEvent()
	Protected Result = 0

	DisableDebugger
	Result = WindowEvent()
	EnableDebugger

	ProcedureReturn Result
EndProcedure
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Please allow OpenWindow inside threads

Post by Fred »

freak wrote:
MachineCode wrote:
freak wrote:Just keep compiling it with version 4.5 and nothing will change. Nobody forces you to port it to the latest version.
But 4.5 doesn't have any of the bug-fixes of the new 5.10 release. That's the problem.
Unless one of them explicitly stops you from finishing the program, what does it matter? Do you need a bugfix for a command that your program doesn't use?

jaPBe is still compiled with 3.94. It doesn't seem to require the latest 5.10 bugfixes.
Do you think we should change this to a warning on Windows ?
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Please allow OpenWindow inside threads

Post by MachineCode »

Fred wrote:Do you think we should change this to a warning on Windows ?
+1

For window events too, obviously.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
auser
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Sep 06, 2006 6:59 am

Re: Please allow OpenWindow inside threads

Post by auser »

freak wrote: Unless one of them explicitly stops you from finishing the program, what does it matter?
Does it matter if we could recommend PB to somebody else or get annoyed from all that screw you? :| Again: It matters because OpenWindow of PB 4.6 is bugged (especially if you use it with threads). And again it matters because we would like to get it as "feature" if it's just a warning. You told us use DisableDebugger. This was wrong. It was a real error and it did not came out without getting annyoing here it seems. Now it changes to a warning - so why not make it a warning then? Even if I get called paranoid because I'm not that magic to create a link to hidden threads: The OpenWindow bug is still there in PB 4.6. The bugfix for OpenWindow found it's way into 5.00 release. I know that because I asked Fred if PB 4.6 is stable enough to use and Fred already checked afterwards via SVN that the Bugfix for OpenWindow found it's way into 5.00. Fred even suggested me already to use 5.00 'windows' lib in 4.6 PB because there was just one change or so. I tried but that "mixed 4.6" did the same stuff like 5.00 afterwards (it throws an error) - however it would be better then using PB 5.00 with DisableDebugger. So back again to the topic (even if you see no reason for that - we would like to get it): If it's really save to use DisableDebugger now could you change the error to a warning - please?
Last edited by auser on Mon Feb 11, 2013 9:51 am, edited 1 time in total.
auser
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Sep 06, 2006 6:59 am

Re: Please allow OpenWindow inside threads

Post by auser »

skywalk wrote:This also begs the question?
Why are threads not handled similarly on advanced OS's like GNU Linux and Mac OS X?
I agree. I'm not sure if there is any GUI in linux that does that same way like windows does. I checked QT and after reading lot of docs it seems to be similar (GUI have to be in main). At least there is some "Wine" that is running windows-apps in linux (and it calls itself to be not an emulator so should run "native"). So in theory it should be possible somehow I guess or all that programs that use the behaviour that worked in windows would not work with Wine... (to be honest I never checked if it works via wine)
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Please allow OpenWindow inside threads

Post by Fred »

It's indeed software only, if you run WINE or VMWare it will work. Native toolkits like QT, GTK and Cocoa doesn't support it, it's a design choice (and a all apps are running with this model, so it is not an issue).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Please allow OpenWindow inside threads

Post by c4s »

Fred @freak wrote:Do you think we should change this to a warning on Windows ?
This sounded like you had changed your mind and wanted to switch the error to a (much more user friendly) warning message.

However the latest(?!) beta has just been released with the following note:
PB 5.10 beta 8 announcement wrote:You can consider this one as final, as nothing should be change code wise [...]
I just tried creating a window inside a thread (on Windows with 5.10b8 of course) and this error message is still popping up... Does this mean that you don't want to change it anymore?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
auser
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Sep 06, 2006 6:59 am

Re: Please allow OpenWindow inside threads

Post by auser »

Shame on me :?
Last edited by auser on Fri Feb 15, 2013 11:15 am, edited 1 time in total.
Post Reply