Index: printing/printing_context_system_dialog_win.cc |
diff --git a/printing/printing_context_system_dialog_win.cc b/printing/printing_context_system_dialog_win.cc |
index 19fc42719ce990af1cd4abe16f25b0657aa3f8b8..b89f1a4e469ac89ca10b34942a95f8fd35a21010 100644 |
--- a/printing/printing_context_system_dialog_win.cc |
+++ b/printing/printing_context_system_dialog_win.cc |
@@ -4,6 +4,7 @@ |
#include "printing/printing_context_system_dialog_win.h" |
+#include "base/auto_reset.h" |
#include "base/message_loop/message_loop.h" |
#include "printing/backend/win_helper.h" |
#include "printing/print_settings_initializer_win.h" |
@@ -84,6 +85,13 @@ void PrintingContextSytemDialogWin::Cancel() { |
} |
HRESULT PrintingContextSytemDialogWin::ShowPrintDialog(PRINTDLGEX* options) { |
+ // Runs always on the UI thread. |
+ static bool is_dialog_shown = false; |
+ if (is_dialog_shown) |
+ return E_FAIL; |
+ // Block opening dialog from nested task. It crashes PrintDlgEx. |
+ base::AutoReset<bool> auto_reset(&is_dialog_shown, true); |
+ |
// Note that this cannot use ui::BaseShellDialog as the print dialog is |
// system modal: opening it from a background thread can cause Windows to |
// get the wrong Z-order which will make the print dialog appear behind the |