Changeset 179744 in webkit
- Timestamp:
- Feb 6, 2015, 6:46:17 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
WebProcess/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
WebProcess/WebPage/gtk/PrinterListGtk.cpp (modified) (1 diff)
-
WebProcess/WebPage/gtk/PrinterListGtk.h (modified) (2 diffs)
-
WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r179736 r179744 1 2015-02-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 ASSERTION FAILED: !m_adoptionIsRequired in WTF::RefCountedBase::ref 4 https://bugs.webkit.org/show_bug.cgi?id=141035 5 6 Reviewed by Sergio Villar Senin. 7 8 Rename PrinterListGtk::singleton() as PrinterListGtk::getOrCreate(), and 9 make it return nullptr when the shared PrinterListGtk object is 10 still being created. This can happen if the nested loop used by 11 gtk_enumerate_printers dispatches a GSource that starts a new 12 synchronous print operation. In that case we just ignore the 13 second print operation, since there's already one ongoing. 14 15 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 16 (WebKit::WebChromeClient::print): Return early if 17 PrinterListGtk::getOrCreate() return nullptr. 18 * WebProcess/WebPage/gtk/PrinterListGtk.cpp: 19 (WebKit::PrinterListGtk::getOrCreate): Return nullptr if the 20 PrinterListGtk is still enumerating the printers. 21 (WebKit::PrinterListGtk::PrinterListGtk): Initialize 22 m_enumeratingPrinters to true before calling 23 gtk_enumerate_printers, and to false once it finishes. 24 (WebKit::PrinterListGtk::singleton): Deleted. 25 (WebKit::PrinterListGtk::enumeratePrintersFunction): Deleted. 26 * WebProcess/WebPage/gtk/PrinterListGtk.h: 27 * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp: Add an 28 assertion here since PrinterListGtk::getOrCreate() should never 29 return nullptr at this point. 30 1 31 2015-02-05 Tim Horton <timothy_horton@apple.com> 2 32 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r179409 r179744 663 663 // The PrinterListGtk class gets the list of printers in the constructor so we just need to ensure there's an instance alive 664 664 // during the synchronous print operation. 665 RefPtr<PrinterListGtk> printerList = PrinterListGtk::singleton(); 665 RefPtr<PrinterListGtk> printerList = PrinterListGtk::getOrCreate(); 666 if (!printerList) { 667 // PrinterListGtk::getOrCreate() returns nullptr when called while a printers enumeration is ongoing. 668 // This can happen if a synchronous print is started by a JavaScript and another one is inmeditaley started 669 // from a JavaScript event listener. The second print operation is handled by the nested main loop used by GTK+ 670 // to enumerate the printers, and we end up here trying to get a reference of an object that is being constructed. 671 // It's very unlikely that the user wants to print twice in a row, and other browsers don't do two print operations 672 // in this particular case either. So, the safest solution is to return early here and ignore the second print. 673 // See https://bugs.webkit.org/show_bug.cgi?id=141035 674 return; 675 } 666 676 #endif 667 677 -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.cpp
r179409 r179744 35 35 PrinterListGtk* PrinterListGtk::s_sharedPrinterList = nullptr; 36 36 37 RefPtr<PrinterListGtk> PrinterListGtk:: singleton()37 RefPtr<PrinterListGtk> PrinterListGtk::getOrCreate() 38 38 { 39 39 if (s_sharedPrinterList) 40 return s_sharedPrinterList ;40 return s_sharedPrinterList->isEnumeratingPrinters() ? nullptr : s_sharedPrinterList; 41 41 42 42 return adoptRef(new PrinterListGtk); 43 43 } 44 44 45 gboolean PrinterListGtk::enumeratePrintersFunction(GtkPrinter* printer)46 {47 ASSERT(s_sharedPrinterList);48 s_sharedPrinterList->addPrinter(printer);49 return FALSE;50 }51 52 45 PrinterListGtk::PrinterListGtk() 53 46 : m_defaultPrinter(nullptr) 47 , m_enumeratingPrinters(true) 54 48 { 55 49 ASSERT(!s_sharedPrinterList); 56 50 s_sharedPrinterList = this; 57 gtk_enumerate_printers(reinterpret_cast<GtkPrinterFunc>(&enumeratePrintersFunction), nullptr, nullptr, TRUE); 51 gtk_enumerate_printers([](GtkPrinter* printer, gpointer) -> gboolean { 52 ASSERT(s_sharedPrinterList); 53 s_sharedPrinterList->addPrinter(printer); 54 return FALSE; 55 }, nullptr, nullptr, TRUE); 56 m_enumeratingPrinters = false; 58 57 } 59 58 -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.h
r179409 r179744 39 39 class PrinterListGtk: public RefCounted<PrinterListGtk> { 40 40 public: 41 static RefPtr<PrinterListGtk> singleton();41 static RefPtr<PrinterListGtk> getOrCreate(); 42 42 ~PrinterListGtk(); 43 43 … … 48 48 PrinterListGtk(); 49 49 50 static gboolean enumeratePrintersFunction(GtkPrinter*);51 50 void addPrinter(GtkPrinter*); 51 bool isEnumeratingPrinters() const { return m_enumeratingPrinters; } 52 52 53 53 Vector<GRefPtr<GtkPrinter>, 4> m_printerList; 54 54 GtkPrinter* m_defaultPrinter; 55 bool m_enumeratingPrinters; 55 56 static PrinterListGtk* s_sharedPrinterList; 56 57 }; -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
r179409 r179744 68 68 m_callbackID = callbackID; 69 69 70 RefPtr<PrinterListGtk> printerList = PrinterListGtk::singleton(); 70 RefPtr<PrinterListGtk> printerList = PrinterListGtk::getOrCreate(); 71 ASSERT(printerList); 71 72 const char* printerName = gtk_print_settings_get_printer(m_printSettings.get()); 72 73 GtkPrinter* printer = printerName ? printerList->findPrinter(printerName) : printerList->defaultPrinter();
Note:
See TracChangeset
for help on using the changeset viewer.