mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-04-16 11:47:22 +02:00
Linux: Fix crash when canceling the print dialog (issue #2341)
This commit is contained in:
parent
3750c59aaa
commit
8b4b6ac2ed
@ -8,7 +8,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "libcef/browser/browser_host_impl.h"
|
|
||||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||||
#include "libcef/browser/print_settings_impl.h"
|
#include "libcef/browser/print_settings_impl.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
@ -157,9 +156,17 @@ void CefPrintDialogLinux::OnPrintStart(int render_process_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefPrintDialogLinux::CefPrintDialogLinux(PrintingContextLinux* context)
|
CefPrintDialogLinux::CefPrintDialogLinux(PrintingContextLinux* context)
|
||||||
: context_(context) {}
|
: context_(context) {
|
||||||
|
DCHECK(context_);
|
||||||
|
browser_ = extensions::GetOwnerBrowserForFrame(
|
||||||
|
context_->render_process_id(), context_->render_frame_id(), NULL);
|
||||||
|
DCHECK(browser_);
|
||||||
|
}
|
||||||
|
|
||||||
CefPrintDialogLinux::~CefPrintDialogLinux() {
|
CefPrintDialogLinux::~CefPrintDialogLinux() {
|
||||||
|
// It's not safe to dereference |context_| during the destruction of this
|
||||||
|
// object because the PrintJobWorker which owns |context_| may already have
|
||||||
|
// been deleted.
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
ReleaseHandler();
|
ReleaseHandler();
|
||||||
}
|
}
|
||||||
@ -187,13 +194,10 @@ void CefPrintDialogLinux::ShowDialog(
|
|||||||
|
|
||||||
callback_ = callback;
|
callback_ = callback;
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
|
|
||||||
context_->render_process_id(), context_->render_frame_id(), NULL);
|
|
||||||
|
|
||||||
CefRefPtr<CefPrintDialogCallbackImpl> callback_impl(
|
CefRefPtr<CefPrintDialogCallbackImpl> callback_impl(
|
||||||
new CefPrintDialogCallbackImpl(this));
|
new CefPrintDialogCallbackImpl(this));
|
||||||
|
|
||||||
if (!handler_->OnPrintDialog(browser.get(), has_selection,
|
if (!handler_->OnPrintDialog(browser_.get(), has_selection,
|
||||||
callback_impl.get())) {
|
callback_impl.get())) {
|
||||||
callback_impl->Disconnect();
|
callback_impl->Disconnect();
|
||||||
OnPrintCancel();
|
OnPrintCancel();
|
||||||
@ -257,10 +261,7 @@ void CefPrintDialogLinux::SetHandler() {
|
|||||||
|
|
||||||
void CefPrintDialogLinux::ReleaseHandler() {
|
void CefPrintDialogLinux::ReleaseHandler() {
|
||||||
if (handler_.get()) {
|
if (handler_.get()) {
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
|
handler_->OnPrintReset(browser_.get());
|
||||||
context_->render_process_id(), context_->render_frame_id(), NULL);
|
|
||||||
|
|
||||||
handler_->OnPrintReset(browser.get());
|
|
||||||
handler_ = NULL;
|
handler_ = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,12 +274,9 @@ bool CefPrintDialogLinux::UpdateSettings(printing::PrintSettings* settings,
|
|||||||
if (!handler_.get())
|
if (!handler_.get())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
|
|
||||||
context_->render_process_id(), context_->render_frame_id(), NULL);
|
|
||||||
|
|
||||||
CefRefPtr<CefPrintSettingsImpl> settings_impl(
|
CefRefPtr<CefPrintSettingsImpl> settings_impl(
|
||||||
new CefPrintSettingsImpl(settings, false, false));
|
new CefPrintSettingsImpl(settings, false, false));
|
||||||
handler_->OnPrintSettings(browser.get(), settings_impl.get(), get_defaults);
|
handler_->OnPrintSettings(browser_.get(), settings_impl.get(), get_defaults);
|
||||||
settings_impl->Detach(NULL);
|
settings_impl->Detach(NULL);
|
||||||
|
|
||||||
context_->InitWithSettings(*settings);
|
context_->InitWithSettings(*settings);
|
||||||
@ -294,13 +292,10 @@ void CefPrintDialogLinux::SendDocumentToPrinter(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
|
|
||||||
context_->render_process_id(), context_->render_frame_id(), NULL);
|
|
||||||
|
|
||||||
CefRefPtr<CefPrintJobCallbackImpl> callback_impl(
|
CefRefPtr<CefPrintJobCallbackImpl> callback_impl(
|
||||||
new CefPrintJobCallbackImpl(this));
|
new CefPrintJobCallbackImpl(this));
|
||||||
|
|
||||||
if (!handler_->OnPrintJob(browser.get(), document_name, path_to_pdf_.value(),
|
if (!handler_->OnPrintJob(browser_.get(), document_name, path_to_pdf_.value(),
|
||||||
callback_impl.get())) {
|
callback_impl.get())) {
|
||||||
callback_impl->Disconnect();
|
callback_impl->Disconnect();
|
||||||
OnJobCompleted();
|
OnJobCompleted();
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#define LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
#define LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
||||||
|
|
||||||
#include "include/cef_print_handler.h"
|
#include "include/cef_print_handler.h"
|
||||||
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
@ -19,7 +20,7 @@
|
|||||||
namespace printing {
|
namespace printing {
|
||||||
class MetafilePlayer;
|
class MetafilePlayer;
|
||||||
class PrintSettings;
|
class PrintSettings;
|
||||||
}
|
} // namespace printing
|
||||||
|
|
||||||
using printing::PrintingContextLinux;
|
using printing::PrintingContextLinux;
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ class CefPrintDialogLinux : public printing::PrintDialogGtkInterface,
|
|||||||
// Printing dialog callback.
|
// Printing dialog callback.
|
||||||
PrintingContextLinux::PrintSettingsCallback callback_;
|
PrintingContextLinux::PrintSettingsCallback callback_;
|
||||||
PrintingContextLinux* context_;
|
PrintingContextLinux* context_;
|
||||||
|
CefRefPtr<CefBrowserHostImpl> browser_;
|
||||||
|
|
||||||
base::FilePath path_to_pdf_;
|
base::FilePath path_to_pdf_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user