raiguard / QuickItemSearch

Factorio mod - quickly search for items in your inventory or connected logistic network.
MIT License
3 stars 0 forks source link

crash: unprotected string vs nil call in on_gui_text_changed #2

Closed slippycheeze closed 4 years ago

slippycheeze commented 4 years ago

I'm not real sure how this can happen, but:

The mod Quick Item Search (1.5.3) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event QuickItemSearch::on_gui_text_changed (ID 2)
__QuickItemSearch__/scripts/gui/functions.lua:40: bad argument #1 of 2 to 'lower' (string expected, got nil)
stack traceback:
    [C]: in function 'lower'
    __QuickItemSearch__/scripts/gui/functions.lua:40: in function 'match_query'
    __QuickItemSearch__/scripts/gui/functions.lua:57: in function 'search'
    __QuickItemSearch__/scripts/gui/qis.lua:123: in function 'handler'
    __flib__/gui.lua:352: in function 'dispatch_handlers'
    __flib__/gui.lua:138: in function <__flib__/gui.lua:138>

I guess a nil check is needed. Possibly also wrapping the handler in a pcall in dispatch_handlers, so that one bug doesn't kill the entire game session...

slippycheeze commented 4 years ago

PS: I have a save with the reproduction, but not details on what mod or whatever is triggering this oddity. I can say:

  local function match_query(name, translation, ignore_unique)
    if not (translation or translations[name]) then
      return false
    end

    return item_data[name] and (ignore_unique or not results[name]) and (show_hidden or not item_data[name].hidden)
      and string.find(string.lower(translation or translations[name]), query)
  end
raiguard commented 4 years ago

Could you send me the save file where this occured, if you have access to it?

eisstoss commented 4 years ago

I also got the same error, attach my save file. It is determined that it is a conflict caused by other mods I have opened. I can enable QuickItemSearch to use it normally https://drive.google.com/file/d/1KEyqpgho7bSuORp2hgJSETeyg8IjZIpO/view?usp=sharing

raiguard commented 4 years ago

Sorry for the delay, this has been fixed for the next release. Turns out I would just not include translations that failed, and some items in one of the mods your using aren't localised properly, so their "translations" were missing, causing the nil and therefore the crash.