Skip to content

Commit fde3dd0

Browse files
committed
Merge branch 'fixes' into feature
2 parents 6f073c6 + 7f52346 commit fde3dd0

3 files changed

Lines changed: 25 additions & 33 deletions

File tree

src/auto4_base.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,6 @@ namespace Automation4 {
221221
});
222222
}
223223

224-
int ProgressSink::ShowDialog(wxDialog *dialog)
225-
{
226-
int ret = 0;
227-
agi::dispatch::Main().Sync([&] { ret = dialog->ShowModal(); });
228-
return ret;
229-
}
230-
231224
BackgroundScriptRunner::BackgroundScriptRunner(wxWindow *parent, std::string const& title)
232225
: impl(new DialogProgress(parent, to_wx(title)))
233226
{

src/auto4_base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ namespace Automation4 {
133133
/// Show the passed dialog on the GUI thread, blocking the calling
134134
/// thread until it closes
135135
void ShowDialog(ScriptDialog *config_dialog);
136-
int ShowDialog(wxDialog *dialog);
137136
wxWindow *GetParentWindow() const { return bsr->GetParentWindow(); }
138137

139138
/// Get the current automation trace level

src/auto4_lua_progresssink.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "compat.h"
3838

39+
#include <libaegisub/dispatch.h>
3940
#include <libaegisub/lua/utils.h>
4041

4142
#include <wx/filedlg.h>
@@ -197,7 +198,6 @@ namespace Automation4 {
197198

198199
int LuaProgressSink::LuaDisplayOpenDialog(lua_State *L)
199200
{
200-
ProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
201201
wxString message(check_wxstring(L, 1));
202202
wxString dir(check_wxstring(L, 2));
203203
wxString file(check_wxstring(L, 3));
@@ -211,26 +211,24 @@ namespace Automation4 {
211211
if (must_exist)
212212
flags |= wxFD_FILE_MUST_EXIST;
213213

214-
wxFileDialog diag(nullptr, message, dir, file, wildcard, flags);
215-
if (ps->ShowDialog(&diag) == wxID_CANCEL) {
216-
lua_pushnil(L);
217-
return 1;
218-
}
219-
220-
if (multiple) {
221-
wxArrayString files;
222-
diag.GetPaths(files);
223-
224-
lua_createtable(L, files.size(), 0);
225-
for (size_t i = 0; i < files.size(); ++i) {
226-
lua_pushstring(L, files[i].utf8_str());
227-
lua_rawseti(L, -2, i + 1);
214+
agi::dispatch::Main().Sync([&] {
215+
wxFileDialog diag(nullptr, message, dir, file, wildcard, flags);
216+
if (diag.ShowModal() == wxID_CANCEL) {
217+
lua_pushnil(L);
218+
} else if (multiple) {
219+
wxArrayString files;
220+
diag.GetPaths(files);
221+
222+
lua_createtable(L, files.size(), 0);
223+
for (size_t i = 0; i < files.size(); ++i) {
224+
lua_pushstring(L, files[i].utf8_str());
225+
lua_rawseti(L, -2, i + 1);
226+
}
227+
} else {
228+
lua_pushstring(L, diag.GetPath().utf8_str());
228229
}
230+
});
229231

230-
return 1;
231-
}
232-
233-
lua_pushstring(L, diag.GetPath().utf8_str());
234232
return 1;
235233
}
236234

@@ -247,13 +245,15 @@ namespace Automation4 {
247245
if (prompt_overwrite)
248246
flags |= wxFD_OVERWRITE_PROMPT;
249247

250-
wxFileDialog diag(ps->GetParentWindow(), message, dir, file, wildcard, flags);
251-
if (ps->ShowDialog(&diag) == wxID_CANCEL) {
252-
lua_pushnil(L);
253-
return 1;
254-
}
248+
agi::dispatch::Main().Sync([&] {
249+
wxFileDialog diag(ps->GetParentWindow(), message, dir, file, wildcard, flags);
250+
if (diag.ShowModal() == wxID_CANCEL) {
251+
lua_pushnil(L);
252+
} else {
253+
lua_pushstring(L, diag.GetPath().utf8_str());
254+
}
255+
});
255256

256-
lua_pushstring(L, diag.GetPath().utf8_str());
257257
return 1;
258258
}
259259
}

0 commit comments

Comments
 (0)