forked from mirrors/gecko-dev
Bug 1660223: Let printer enumeration run to completion, to avoid a GTK bug. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D195949
This commit is contained in:
parent
f422e6a29b
commit
bf29a3b68b
2 changed files with 17 additions and 1 deletions
|
|
@ -276,6 +276,12 @@ gboolean nsDeviceContextSpecGTK::PrinterEnumerator(GtkPrinter* aPrinter,
|
||||||
gpointer aData) {
|
gpointer aData) {
|
||||||
nsDeviceContextSpecGTK* spec = (nsDeviceContextSpecGTK*)aData;
|
nsDeviceContextSpecGTK* spec = (nsDeviceContextSpecGTK*)aData;
|
||||||
|
|
||||||
|
if (spec->mHasEnumerationFoundAMatch) {
|
||||||
|
// We're already done, but we're letting the enumeration run its course,
|
||||||
|
// to avoid a GTK bug.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the printer whose name matches the one inside the settings.
|
// Find the printer whose name matches the one inside the settings.
|
||||||
nsString printerName;
|
nsString printerName;
|
||||||
nsresult rv = spec->mPrintSettings->GetPrinterName(printerName);
|
nsresult rv = spec->mPrintSettings->GetPrinterName(printerName);
|
||||||
|
|
@ -293,7 +299,14 @@ gboolean nsDeviceContextSpecGTK::PrinterEnumerator(GtkPrinter* aPrinter,
|
||||||
NS_DispatchToCurrentThread(
|
NS_DispatchToCurrentThread(
|
||||||
NewRunnableMethod("nsDeviceContextSpecGTK::StartPrintJob", spec,
|
NewRunnableMethod("nsDeviceContextSpecGTK::StartPrintJob", spec,
|
||||||
&nsDeviceContextSpecGTK::StartPrintJob));
|
&nsDeviceContextSpecGTK::StartPrintJob));
|
||||||
return TRUE;
|
|
||||||
|
// We're already done, but we need to let the enumeration run its course,
|
||||||
|
// to avoid a GTK bug. So we record that we've found a match and
|
||||||
|
// then return FALSE.
|
||||||
|
// TODO: If/when we can be sure that GTK handles this OK, we could
|
||||||
|
// return TRUE to avoid some needless enumeration.
|
||||||
|
spec->mHasEnumerationFoundAMatch = true;
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,6 +330,7 @@ void nsDeviceContextSpecGTK::StartPrintJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsDeviceContextSpecGTK::EnumeratePrinters() {
|
void nsDeviceContextSpecGTK::EnumeratePrinters() {
|
||||||
|
mHasEnumerationFoundAMatch = false;
|
||||||
gtk_enumerate_printers(&nsDeviceContextSpecGTK::PrinterEnumerator, this,
|
gtk_enumerate_printers(&nsDeviceContextSpecGTK::PrinterEnumerator, this,
|
||||||
nullptr, TRUE);
|
nullptr, TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ class nsDeviceContextSpecGTK : public nsIDeviceContextSpec {
|
||||||
nsCString mSpoolName;
|
nsCString mSpoolName;
|
||||||
nsCOMPtr<nsIFile> mSpoolFile;
|
nsCOMPtr<nsIFile> mSpoolFile;
|
||||||
nsCString mTitle;
|
nsCString mTitle;
|
||||||
|
// Helper for EnumeratePrinters / PrinterEnumerator:
|
||||||
|
bool mHasEnumerationFoundAMatch = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EnumeratePrinters();
|
void EnumeratePrinters();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue