Page 1 of 1

[Not a bug] ExamineDesktops()

Posted: Tue Jun 13, 2017 1:29 pm
by Dude
[Edit] Since I can't post my entire code, and the problem shown below is apparently no help, so don't worry about it.

This bug seems pretty self-explanatory. I just called ExamineDesktops(), and then DesktopWidth() is complaining that I didn't? :shock:

And yes, the "monitors" variable is local to that code (it's NOT global or set anywhere else).

Image

Re: ExamineDesktops() must be called bug

Posted: Tue Jun 13, 2017 4:51 pm
by mk-soft
No problem her...

PB-Version ?
OS-Version ?

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 12:13 am
by Dude
I have Windows 7 Ultimate (64-bit). Running PureBasic 5.60 (32-bit version), as shown in IDE status bar.

It doesn't happen all the time; just occasionally, so it's annoying. ExamineDesktop() is in a thread, and that's the ONLY place in the source where ExamineDesktops() is called; and thread safety is on.

I don't even know why the red error line is happening. DesktopWidth() should only be called if "monitors" is non-zero (ie. successful).

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 9:17 am
by Fluid Byte
Assumptions, nothing more. Show us the whole code or a snippet that demonstrates the problem, otherwise this discussion is pointless.

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 10:51 am
by Dude
Fluid Byte wrote:Show us the whole code or a snippet that demonstrates the problem
I think my screenshot does that job quite nicely. No? The program flow and logic is there to see.

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 11:10 am
by luis
Dude wrote: I think my screenshot does that job quite nicely. No?
No.
Dude wrote: ExamineDesktop() is in a thread
good lord of programmers hit him on the head ... I don't see any of that in the self-explanatory screenshot.

"thread" in the window is not enough to follow the code flow, also why one should manually copy some code to test it when he can paste it ?

Not to mention the code shown is just a piece of something, not something you can run.

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 11:15 am
by Dude
Last time I checked, PureBasic was a top-down compiler... so if ExamineDesktops() appears a few lines before DesktopWidth(), as shown in my screenshot, then why is this error even occurring? That's what this bug report is all about.

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 12:18 pm
by Little John
Dude wrote:
Fluid Byte wrote:Show us the whole code or a snippet that demonstrates the problem
I think my screenshot does that job quite nicely. No?
No.
Dude wrote:That's what this bug report is all about.
As already has been told you, this is not a serious bug report at all.
[u]Fred[/u] wrote:You will need to post full working snippet if you want us to look at a bug, because toying with an incomplete code is just waste of time as we don't even know if we meet the same conditions.

Re: ExamineDesktops() must be called bug

Posted: Wed Jun 14, 2017 12:22 pm
by Dude
Little John wrote:As already has been told you, this is not a serious bug report at all.
Okay, forget it. I'll retract the report. Sorry for wasting everyone's time.

Re: [Not a bug] ExamineDesktops()

Posted: Wed Jun 14, 2017 12:51 pm
by luis
But Dude, you don't need to retract it, maybe it's a bug.
You just have to post some runnable code showing the problem, even if does not happen every time.
You have a big advantage in trying to do so compared to us, since you have some actual code where this is happening.

For example, this works for me

Code: Select all

CompilerIf (#PB_Compiler_Thread = 0)
 CompilerError "Please enable THREADSAFE in the compiler options"
CompilerEndIf

Procedure t (dummy)
 d = ExamineDesktops()
 If d = 0
    Debug "ouch"
    CallDebugger
 EndIf

 x = DesktopWidth(0)
 y = DesktopHeight(0)
 Debug x
EndProcedure

Procedure main()
 h = CreateThread(@t(), 0)
 WaitThread(h)
EndProcedure

For k = 1 To 1000
    main()
Next
Anyway, if you tried to create a smaller code reproducing the problem and you didn't succeed then ok.
A "generic" heads up about a problem even it's not confirmed by others may still have some value for the developer who has access to the source code of those functions.
But you didn't say that. :wink:

Re: [Not a bug] ExamineDesktops()

Posted: Wed Jun 14, 2017 1:40 pm
by Dude
All I want to know, why does DesktopWidth() fail when ExamineDesktops() was just called before it? That's the "bug". That error should ONLY occur if ExamineDesktops() was NOT called first, right? But we can all plainly see from my screenshot that it WAS called, literally just a few lines prior. Not in another thread. Not elsewhere in my code. Doesn't make sense.

Re: [Not a bug] ExamineDesktops()

Posted: Wed Jun 14, 2017 2:11 pm
by Little John
Dude wrote:All I want to know, why does DesktopWidth() fail when ExamineDesktops() was just called before it?
And it seems that you are not the only one who wants to know that ...

Anyway, just shouting "Bug!" doesn't give the answer. If you want to help us finding out the reason why, it is essential that we first can reproduce the issue! And this is especially important for the PB team for fixing the bug, BTW (in case this turns out to be actually a bug).

Make a copy of your program and remove all code that is not needed for reproducing the issue, until you have isolated the problem. Yes, it is a tedious process, but that's the only way. Me and many other people here have done so in the past dozens of times. So maybe you want to do so as well in order to get your answer, and perhaps also to contribute to improving PureBasic?