mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 04:17:31 +09:00
[gtk] Let printer enumeration run to completion, to avoid a GTK bug.
This commit is contained in:
parent
fd949d3245
commit
ce3cc6b74d
2 changed files with 17 additions and 1 deletions
|
|
@ -250,6 +250,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.
|
||||||
nsXPIDLString printerName;
|
nsXPIDLString printerName;
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
|
|
@ -266,7 +272,14 @@ gboolean nsDeviceContextSpecGTK::PrinterEnumerator(GtkPrinter *aPrinter,
|
||||||
// GTK bug (https://bugzilla.gnome.org/show_bug.cgi?id=753041). We
|
// GTK bug (https://bugzilla.gnome.org/show_bug.cgi?id=753041). We
|
||||||
// sidestep this by deferring the print to the next tick.
|
// sidestep this by deferring the print to the next tick.
|
||||||
NS_DispatchToCurrentThread(NewRunnableMethod(spec, &nsDeviceContextSpecGTK::StartPrintJob));
|
NS_DispatchToCurrentThread(NewRunnableMethod(spec, &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 here to avoid some needless enumeration.
|
||||||
|
spec->mHasEnumerationFoundAMatch = true;
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,6 +303,7 @@ void nsDeviceContextSpecGTK::StartPrintJob() {
|
||||||
void
|
void
|
||||||
nsDeviceContextSpecGTK::EnumeratePrinters()
|
nsDeviceContextSpecGTK::EnumeratePrinters()
|
||||||
{
|
{
|
||||||
|
mHasEnumerationFoundAMatch = false;
|
||||||
gtk_enumerate_printers(&nsDeviceContextSpecGTK::PrinterEnumerator, this,
|
gtk_enumerate_printers(&nsDeviceContextSpecGTK::PrinterEnumerator, this,
|
||||||
nullptr, TRUE);
|
nullptr, TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ protected:
|
||||||
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…
Add table
Add a link
Reference in a new issue