RadioButtons, QuerySongs and ProcessMessages bug

Beta Testing for Windows Products and plugins

Moderator: Gurus

ZvezdanD
Posts: 3265
Joined: Thu Jun 08, 2006 7:40 pm

RadioButtons, QuerySongs and ProcessMessages bug

Post by ZvezdanD »

If I use QuerySongs and ProcessMessages in the RadioButton's event handler, none control is responsible, even the dialog box could not be moved, until the first click anywhere on that dialog box - after that click everything works fine. CheckBoxes don't have such problem. Here is the test script, you could find it under the Edit menu, (the first radio button works normally because it is without problematic code, the check box also works normally even with same problematic code):

Code: Select all

Option Explicit

Dim rdbTest1

Sub OnStartUp()
    Dim mnuTest

    Set mnuTest = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
    mnuTest.Caption = "Zvezdan's Test"
    mnuTest.OnClickFunc = "TestForm"
    mnuTest.UseScript = Script.ScriptPath
End Sub

Sub TestForm(Item)
    Dim oForm
    Dim rdbTest2
    Dim chkTest
    Dim btnClose
    Dim i

    Set oForm = SDB.UI.NewForm
    oForm.Common.SetRect 100, 100, 300, 200
    oForm.BorderStyle = 3
    oForm.FormPosition = 4
    oForm.Caption = "Zvezdan's Test"

    Set rdbTest1 = SDB.UI.NewRadioButton(oForm)
    rdbTest1.Common.SetRect 10, 10, 100, 21
    rdbTest1.Caption = "Normal"
    Script.RegisterEvent rdbTest1.Common, "OnClick", "rdbTest1_OnClick"

    Set rdbTest2 = SDB.UI.NewRadioButton(oForm)
    rdbTest2.Common.SetRect 10, 40, 100, 21
    rdbTest2.Caption = "With ProcessMessages"
    Script.RegisterEvent rdbTest2.Common, "OnClick", "rdbTest2_OnClick"

    Set chkTest = SDB.UI.NewCheckBox(oForm)
    chkTest.Common.SetRect 140, 40, 100, 21
    chkTest.Caption = "With ProcessMessages"
    Script.RegisterEvent chkTest.Common, "OnClick", "chkTest_OnClick"

    Set btnClose = SDB.UI.NewButton(oForm)
    btnClose.Caption = "Close"
    btnClose.Common.SetRect 120, 120, 80, 22
    btnClose.Cancel = True
    btnClose.ModalResult = 2

    oForm.showModal
End Sub

Sub rdbTest1_OnClick(oItem)
    SDB.ProcessMessages
End Sub

Sub rdbTest2_OnClick(oItem)
    Dim oSongIter

    oItem.Common.Enabled = False
    rdbTest1.Common.Enabled = False
    Set oSongIter = SDB.Database.QuerySongs("ID > 0")
    Do While Not oSongIter.EOF
        oSongIter.Next
        SDB.ProcessMessages
    Loop
    Set oSongIter = Nothing
    oItem.Common.Enabled = True
    rdbTest1.Common.Enabled = True
End Sub

Sub chkTest_OnClick(oItem)
    Dim oSongIter

    oItem.Common.Enabled = False
    Set oSongIter = SDB.Database.QuerySongs("ID > 0")
    Do While Not oSongIter.EOF
        oSongIter.Next
        SDB.ProcessMessages
    Loop
    Set oSongIter = Nothing
    oItem.Common.Enabled = True
End Sub
My Track Redirection script has such problem in its Create Redirections for Duplicates/Folders dialog box, but only if there are many displayed tracks. The test script from above has always reproducible bug.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2