From 2d6aa340faf5409f1beb50193590b411f515d004 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 1 Aug 2024 11:04:56 +0200 Subject: tdf#162289 Update printer info before getting default printer Move the call to `Printer::updatePrinters` to update the printer infos from the print dialog ctor to the beginning of `Printer::PreparePrintJob` (which is the only method potentially creating a print dialog) to make sure that the printer infos (including the default printer) are already up to date there. This e.g. makes sure that the current CUPS default printer on Linux gets preselected the next time the print dialog gets opened if it was changed while LO is running. (Otherwise, it would only be preselected as expected when the print dialog gets opened, closed and reopened again.) For macOS, there was already code to explicitly call `Printer::updatePrinters` in case the dialog was not shown. Drop that, as it happens unconditionally at the beginning now. Change-Id: I5cd530c0c9801bde88e40f5ac2220feb0e8d4247 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171371 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/source/gdi/print3.cxx | 12 ++---------- vcl/source/window/printdlg.cxx | 2 -- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 4c86484c8a3b..5b5226717774 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -341,6 +341,8 @@ void Printer::PrintJob(const std::shared_ptr& i_xController, bool Printer::PreparePrintJob(std::shared_ptr xController, const JobSetup& i_rInitSetup) { + Printer::updatePrinters(); + // check if there is a default printer; if not, show an error box (if appropriate) if( GetDefaultPrinterName().isEmpty() ) { @@ -537,16 +539,6 @@ bool Printer::PreparePrintJob(std::shared_ptr xController, { } } -#ifdef MACOSX - else - { - // The PrintDialog updates the printer list in its constructor so do - // the same for printers that bring up their own dialog since. Not - // sure if this is needed or not on Windows or X11, so limit only to - // macOS for now. - Printer::updatePrinters(); - } -#endif xController->pushPropertiesToPrinter(); return true; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index faa8d7179cb6..9e24b7c7d5c6 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -591,8 +591,6 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, std::shared_ptrget_label(); - Printer::updatePrinters(); - mxPrinters->append_text(maPrintToFileText); // fill printer listbox std::vector< OUString > rQueues( Printer::GetPrinterQueues() ); -- cgit