Bug #44813 Calling Workbench:requestFileSave in a plugin sets document's unsaved status
Submitted: 12 May 2009 6:42 Modified: 12 Nov 2009 15:37
Reporter: Thomas Henlich Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.2.3 OSS Beta OS:Any
Assigned to: Alfredo Kojima CPU Architecture:Any

[12 May 2009 6:42] Thomas Henlich
Description:
When calling a function like

function rfstest(obj)
  local path
  path = Workbench:requestFileSave("Caption", "SQL Files (*.sql)|*.sql")
end

from a plugin, with an unmodified document open or after creating a new document, running the plugin causes the document's status to be set to "unsaved" (asterisk in title bar) as soon as the file selection dialog opens.

How to repeat:
1. Install this plugin:
====
function getModuleInfo()
  return {
    name= "rfstest",
    author= "rfstest",
    version= "1.0",
    implements= "PluginInterface",
    functions= {
      "getPluginInfo:l<o@app.Plugin>:",
      "rfstest:i:o@db.Catalog"
    }
  }
end

function objectPluginInput(type)
  return grtV.newObj("app.PluginObjectInput", {objectStructName= type})
end

function getPluginInfo()
    local l
    local plugin
    l= grtV.newList("object", "app.Plugin")
    plugin= grtV.newObj("app.Plugin", {
      name= "wb.catalog.util.rfstest",
      caption= "rfstest",
      moduleName= "rfstest",
      pluginType= "normal",
      moduleFunctionName= "rfstest",
      inputValues= {objectPluginInput("db.Catalog")},
      rating= 100,
      showProgress= 0,
      groups= {"Catalog/Utilities", "Menu/Utilities"}
    })

    plugin.inputValues[1].owner= plugin
    grtV.insert(l, plugin)
    return l
end

function rfstest(obj)
  local path
  path = Workbench:requestFileSave("Caption", "SQL Files (*.sql)|*.sql")
  -- 5.2.12 OSS Beta: Document is marked as modified (*) at this point
end
===

2. Create a new document
3. Run the plugin (rfstest)

Suggested fix:
Document's status should not be modified upon calling requestFileSave.
[26 May 2009 12:23] Thomas Henlich
Cannot reproduce on 5.2.1
[22 Sep 2009 9:00] Thomas Henlich
Bug can be reproduced in 5.2.3
[11 Nov 2009 23:31] Johannes Taxacher
fixed in sourcecode. will be included in 5.2.7
[12 Nov 2009 15:37] Tony Bedford
An entry has been added to the 5.2.7 changelog:

When running a plugin that called a function such as the following, the document's status was set to “unsaved”, and an asterisk was displayed in the title bar, as soon as the file selection dialog opened. This occurred even for a new document, or an unmodified document.

function rfstest(obj)
  local path
  path = Workbench:requestFileSave("Caption", "SQL Files (*.sql)|*.sql")
end