Modify

Opened 14 years ago

Closed 13 years ago

#1944 closed Bug (No Bug)

AdlibUnRegister not working trusty

Reported by: Devol Owned by:
Milestone: Component: AutoIt
Version: 3.3.6.1 Severity: None
Keywords: Cc:

Description

Hello,

Here an example:

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $Label, $iPos = 0 , $sleep = 10

$Form1 = GUICreate("Adlibtest - Sleep("&$sleep&")", 240, 100, 990, 30)
GUISetOnEvent(-3, "_Exit")
$Label = GUICtrlCreateLabel("Testlabel", 25, 14, 300, 16)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Start",15,50,60,40)
GUICtrlSetOnEvent(-1,"_startadlib")
$Button2 = GUICtrlCreateButton("Stop",120,50,60,40)
GUICtrlSetOnEvent(-1,"_stopadlib")
GUISetState(@SW_SHOW)

While Sleep($sleep) ; the higher the sleep , the more often the labelswitch fails
WEnd

Func _startadlib()
GUICtrlSetData($Label,"Running")
AdlibRegister("_Laufschrift")
EndFunc

Func _stopadlib()
AdlibUnRegister("_Laufschrift")
GUICtrlSetData($Label,"Stopped") ; labelswitch failing sometimes 
EndFunc

Func _Exit()
    Exit
EndFunc

Func _Laufschrift()
    GUICtrlSetData($Label, StringMid("Running", $iPos) & "           " & "Running")
    $iPos += 1.8
    If $iPos > StringLen("Running") Then $iPos = 0
EndFunc

I tested this script on several pcs but the behavoir is always the same.
AdlibUnRegister

sometimes

fails and the subsequent command is not being executed.

You can try the examplescript , just click the buttons "Start" and "Stop" by turns.(wait 1-2 secs. before clicking stop)
Sooner or later the label will be stopped on "Running Running Running" despite of the GuictrlsetData($Label,"Stopped").

Bug or not? :)

Greetz Devol

PS: I talked to the german forum before opening this ticket.

Attachments (0)

Change History (11)

comment:1 follow-up: Changed 14 years ago by BrewManNH

It's working for me, every time I hit Stop, it changes the label to Stopped. I even put the sleep at 1 second and still no issues with it.

comment:2 in reply to: ↑ 1 Changed 14 years ago by anonymous

Replying to BrewManNH:

It's working for me, every time I hit Stop, it changes the label to Stopped. I even put the sleep at 1 second and still no issues with it.

Sorry i had problems with the edit-function , the sleep doesn`t really matter , use 50ms to try , the error really exists(tested with some user in the german forum before) , the problem is that it appears randomly.

comment:3 Changed 14 years ago by mvg

  • Random: General ratio might be helpful here. (1:2, 1:10, etc)
  • System: Some system data on the PC's you have encountered this problem. (like "Environment(Language:0413 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 OS:X86)"( SciTE4AutoIT3,scriptmode)

    PS: I talked to the german forum before opening this ticket.

  • Link: So it seems ... http://www.autoit.de/index.php?page=Thread&threadID=27479

comment:4 follow-up: Changed 14 years ago by mvg

O yea ... your reporting on 3.3.6.1. If you can, see if the current latest beta 3.3.7.x(you fill in the x) is also giving you the same problem/error.

comment:5 in reply to: ↑ 4 Changed 14 years ago by Devol

Replying to mvg:

O yea ... your reporting on 3.3.6.1. If you can, see if the current latest beta 3.3.7.x(you fill in the x) is also giving you the same problem/error.

So , the error also appears in beta v3.3.7.8, tested on Win7 Prof. SP1 x64 , WinXP Prof. SP2/3 x86.

comment:6 Changed 14 years ago by mvg

@dev's
Thanks for having me on delayed viewing.

comment:7 Changed 13 years ago by Devol

@dev`s
Did someone already took a look on it?

comment:8 Changed 13 years ago by Jpm

From my point of view there is no bug but just a race condition.
When the AdlibUnRegister is requested the previous execution can be just beginning. No way to stop it but the GUICtrlSetData($Label,"Stopped") will be overwrite with the end of execution of _Laufschrift()
some global variable can be set to reflect that we want to stop or ad a slight delay before executing GUICtrlSetData($Label,"Stopped") that will force the execution of the previous Adlib.
Remember AutoIt is not multithreaded so Adlib is executing between statements

Func _stopadlib()
AdlibUnRegister("_Laufschrift")
Sleep(500)
GUICtrlSetData($Label,"Stopped") ; labelswitch failing sometimes 
EndFunc

comment:9 follow-up: Changed 13 years ago by Devol

Sorry , but the Sleep doesn`t solve the problem(just tried it).
AdlibUnregister should stop a registered function to be executed, right?
So what if it`s important that an function really needs to be stopped?
In my opinion it`s a bug, sry..

comment:10 in reply to: ↑ 9 Changed 13 years ago by Devol

Replying to Devol:

Sorry , but the Sleep doesn`t solve the problem(just tried it).
AdlibUnregister should stop a registered function to be executed, right?
So what if it`s important that an function really needs to be stopped?
In my opinion it`s a bug, sry..

It only works with global variables:

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $Label, $iPos = 0 , $sleep = 30 , $schalter

$Form1 = GUICreate("Adlibtest - Sleep("&$sleep&")", 240, 100, 990, 30)
GUISetOnEvent(-3, "_Exit")
$Label = GUICtrlCreateLabel("Testlabel", 25, 14, 300, 16)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Start",15,50,60,40)
GUICtrlSetOnEvent(-1,"_startadlib")
$Button2 = GUICtrlCreateButton("Stop",120,50,60,40)
GUICtrlSetOnEvent(-1,"_stopadlib")
GUISetState(@SW_SHOW)

While Sleep($sleep) ; the higher the sleep , the more often the labelswitch fails
WEnd

Func _startadlib()
GUICtrlSetData($Label,"Running")
$schalter=0
AdlibRegister("_Laufschrift")
EndFunc

Func _stopadlib()
$schalter = 1
AdlibUnRegister("_Laufschrift")
GUICtrlSetData($Label,"Stopped") ; labelswitch failing sometimes
EndFunc

Func _Exit()
    Exit
EndFunc

Func _Laufschrift()
	If 	$schalter = 1 Then Return
    GUICtrlSetData($Label, StringMid("Running", $iPos) & "           " & "Running")
    $iPos += 1.8
    If $iPos > StringLen("Running") Then $iPos = 0
EndFunc

comment:11 Changed 13 years ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

I agree that a global is "the solution" but the sleep can work in some case at least on my system.
There is nothing with the current implementation of AutoIt that we can do inside AutoIt.
You need to use Global to avoid such interaction between Adlib's

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.