Fix number of available printers in CUPS support.
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>
Wed, 10 Oct 2012 18:43:50 +0000 (15:43 -0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 13 Oct 2012 03:51:19 +0000 (05:51 +0200)
If the number of available printers changes, we want
to update the count. Additionally, if that number has
gone to zero, we want to ensure that the number of
available printers in the static object is reset to
zero.

This fixes a crash that occurs if:
 * You print
 * You kill cupsd (or it crashes because you're porting it and your port is unstable)
 * You try to print again before restarting it.

Change-Id: I6c6069db9d800ce7426e75df760829fea278e56e
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/printsupport/kernel/qcups.cpp

index dd38552..ea18f1e 100644 (file)
@@ -135,7 +135,7 @@ QCUPSSupport::QCUPSSupport()
     if (!isAvailable())
         return;
 
-    prnCount = _cupsGetDests(&printers);
+    qt_cups_num_printers = prnCount = _cupsGetDests(&printers);
 
     for (int i = 0; i <  prnCount; ++i) {
         if (printers[i].is_default) {