win: Run async save dialog in new thread
This commit is contained in:
parent
253bacdf1d
commit
c20e1e9d82
1 changed files with 24 additions and 10 deletions
|
@ -134,6 +134,19 @@ void RunOpenDialogInNewThread(const RunState& run_state,
|
||||||
run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread);
|
run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RunSaveDialogInNewThread(const RunState& run_state,
|
||||||
|
atom::NativeWindow* parent,
|
||||||
|
const std::string& title,
|
||||||
|
const base::FilePath& default_path,
|
||||||
|
const Filters& filters,
|
||||||
|
const SaveDialogCallback& callback) {
|
||||||
|
base::FilePath path;
|
||||||
|
bool result = ShowSaveDialog(parent, title, default_path, filters, &path);
|
||||||
|
run_state.ui_message_loop->PostTask(FROM_HERE,
|
||||||
|
base::Bind(callback, result, path));
|
||||||
|
run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||||
|
@ -194,11 +207,6 @@ void ShowOpenDialog(atom::NativeWindow* parent,
|
||||||
if (!thread->Start())
|
if (!thread->Start())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (parent)
|
|
||||||
EnableWindow(
|
|
||||||
static_cast<atom::NativeWindowViews*>(parent)->GetAcceleratedWidget(),
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
RunState state = { thread, base::MessageLoop::current() };
|
RunState state = { thread, base::MessageLoop::current() };
|
||||||
thread->message_loop()->PostTask(
|
thread->message_loop()->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
|
@ -246,15 +254,21 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowSaveDialog(atom::NativeWindow* parent_window,
|
void ShowSaveDialog(atom::NativeWindow* parent,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
const base::FilePath& default_path,
|
const base::FilePath& default_path,
|
||||||
const Filters& filters,
|
const Filters& filters,
|
||||||
const SaveDialogCallback& callback) {
|
const SaveDialogCallback& callback) {
|
||||||
base::FilePath path;
|
base::Thread* thread = new base::Thread("AtomShell_FileDialogThread");
|
||||||
bool result = ShowSaveDialog(parent_window, title, default_path, filters,
|
thread->init_com_with_mta(false);
|
||||||
&path);
|
if (!thread->Start())
|
||||||
callback.Run(result, path);
|
return;
|
||||||
|
|
||||||
|
RunState state = { thread, base::MessageLoop::current() };
|
||||||
|
thread->message_loop()->PostTask(
|
||||||
|
FROM_HERE,
|
||||||
|
base::Bind(&RunSaveDialogInNewThread, state, parent, title, default_path,
|
||||||
|
filters, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace file_dialog
|
} // namespace file_dialog
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue