Bug 680696 - Remove nsPSPrinterList::Init; r=roc
authorMs2ger <ms2ger@gmail.com>
Thu, 25 Aug 2011 10:46:02 +0200
changeset 75848 c5b2cbf6e31be28d0b941fb12117e960a603870b
parent 75847 7dfa2501f1512452d4f1870de11e66e5bb06a1a7
child 75872 f6b61dde6a159dc3d5ea30c387b6c95687d35400
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersroc
bugs680696
milestone9.0a1
Bug 680696 - Remove nsPSPrinterList::Init; r=roc
widget/src/gtk2/nsDeviceContextSpecG.cpp
widget/src/gtk2/nsPSPrinters.cpp
widget/src/gtk2/nsPSPrinters.h
--- a/widget/src/gtk2/nsDeviceContextSpecG.cpp
+++ b/widget/src/gtk2/nsDeviceContextSpecG.cpp
@@ -968,21 +968,19 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::Di
 //----------------------------------------------------------------------
 nsresult GlobalPrinters::InitializeGlobalPrinters ()
 {
   if (PrintersAreAllocated()) {
     return NS_OK;
   }
 
   mGlobalPrinterList = new nsTArray<nsString>();
-  if (!mGlobalPrinterList) 
-    return NS_ERROR_OUT_OF_MEMORY;
 
   nsPSPrinterList psMgr;
-  if (NS_SUCCEEDED(psMgr.Init()) && psMgr.Enabled()) {
+  if (psMgr.Enabled()) {
     /* Get the list of PostScript-module printers */
     // XXX: this function is the only user of GetPrinterList
     // So it may be interesting to convert the nsCStrings
     // in this function, we would save one loop here
     nsTArray<nsCString> printerList;
     psMgr.GetPrinterList(printerList);
     for (PRUint32 i = 0; i < printerList.Length(); i++)
     {
--- a/widget/src/gtk2/nsPSPrinters.cpp
+++ b/widget/src/gtk2/nsPSPrinters.cpp
@@ -53,27 +53,23 @@ using namespace mozilla;
 #define NS_CUPS_PRINTER "CUPS/"
 #define NS_CUPS_PRINTER_LEN (sizeof(NS_CUPS_PRINTER) - 1)
 
 /* dummy printer name for the gfx/src/ps driver */
 #define NS_POSTSCRIPT_DRIVER_NAME "PostScript/"
 
 nsCUPSShim gCupsShim;
 
-/* Initialize the printer manager object */
-nsresult
-nsPSPrinterList::Init()
+nsPSPrinterList::nsPSPrinterList()
 {
     // Should we try cups?
-    PRBool useCups =
-        Preferences::GetBool("print.postscript.cups.enabled", PR_TRUE);
-    if (useCups && !gCupsShim.IsInitialized()) {
+    if (Preferences::GetBool("print.postscript.cups.enabled", PR_TRUE) &&
+        !gCupsShim.IsInitialized()) {
         gCupsShim.Init();
     }
-    return NS_OK;
 }
 
 
 /* Check whether the PostScript module has been disabled at runtime */
 PRBool
 nsPSPrinterList::Enabled()
 {
     const char *val = PR_GetEnv("MOZILLA_POSTSCRIPT_ENABLED");
--- a/widget/src/gtk2/nsPSPrinters.h
+++ b/widget/src/gtk2/nsPSPrinters.h
@@ -42,22 +42,17 @@
 #include "nsString.h"
 #include "nsTArray.h"
 #include "prtypes.h"
 
 class nsCUPSShim;
 
 class nsPSPrinterList {
     public:
-        /**
-         * Initialize a printer manager object.
-         * @return NS_ERROR_NOT_INITIALIZED if unable to access prefs
-         *         NS_OK for successful initialization.
-         */
-        nsresult Init();
+        nsPSPrinterList();
 
         /**
          * Is the PostScript module enabled or disabled?
          * @return PR_TRUE if enabled,
          *         PR_FALSE if not.
          */
         PRBool Enabled();