1 Reply Latest reply on Jun 25, 2010 2:34 PM by johnrellis

    4-argument observer functions have problems?

    johnrellis Most Valuable Participant

      The 4-argument form of observer functions passed to observableTable:addObserver appears to be buggy when used with popup menus.  After a small number of invocations of the menu, the observer function will stop getting called.  I'll report this as a bug soon unless someone points out any misunderstanding I may have.

       

      Here's a short test program that illustrates the behavior:

       

      local LrBinding = import 'LrBinding'
      local LrDialogs = import 'LrDialogs'
      local LrFunctionContext = import 'LrFunctionContext'
      local LrView = import 'LrView'

      LrFunctionContext.callWithContext ("Test", function (context)
        LrDialogs.attachErrorDialogToFunctionContext (context)
        local f = LrView.osFactory()
        local p = LrBinding.makePropertyTable (context)
        p:addObserver ("m3", function (p, k, v) p.e3 = v end)
        p:addObserver ("m4", {}, function (t, p, k, v) p.e4 = v end)
        LrDialogs.presentModalDialog {title = "Test",
          contents = f:column {bind_to_object = p,
            f:row {f:static_text {title = "3-arg observer: "},
                   f:popup_menu {value = LrView.bind ("m3"),
                                 items = {"A", "B"}},
                   f:edit_field {value = LrView.bind ("e3")}},
            f:row {f:static_text {title = "4-arg observer: "},
                   f:popup_menu {value = LrView.bind ("m4"),
                                 items = {"A", "B"}},
                   f:edit_field {value = LrView.bind ("e4")}}}}
        end)

       

      You can invoke the menu "3-arg observer" as many times as you want, and its observer will continue to be called (which updates its edit field). But after invoking the menu "4-arg observer" 10 to 20 times, the observer stops getting called. (In my actual plugin, this would happen after invoking the menu just a couple of times.)

       

      The problem occurs with my larger catalog (16K photos) but not with a small test catalog.