This commit is contained in:
Lana Steuck 2012-06-25 21:34:27 -07:00
commit 0a5cba6501
5 changed files with 27 additions and 10 deletions

View File

@ -33,7 +33,7 @@ package sun.font;
import sun.font.GlyphLayout.*; import sun.font.GlyphLayout.*;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.Locale; import java.util.Locale;
/* /*
@ -129,9 +129,9 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory
// !!! don't need this unless we have more than one sun layout engine... // !!! don't need this unless we have more than one sun layout engine...
public LayoutEngine getEngine(LayoutEngineKey key) { public LayoutEngine getEngine(LayoutEngineKey key) {
HashMap cache = (HashMap)cacheref.get(); ConcurrentHashMap cache = (ConcurrentHashMap)cacheref.get();
if (cache == null) { if (cache == null) {
cache = new HashMap(); cache = new ConcurrentHashMap();
cacheref = new SoftReference(cache); cacheref = new SoftReference(cache);
} }

View File

@ -429,6 +429,7 @@ public class ServiceDialog extends JDialog implements ActionListener {
ValidatingFileChooser jfc = new ValidatingFileChooser(); ValidatingFileChooser jfc = new ValidatingFileChooser();
jfc.setApproveButtonText(getMsg("button.ok")); jfc.setApproveButtonText(getMsg("button.ok"));
jfc.setDialogTitle(getMsg("dialog.printtofile")); jfc.setDialogTitle(getMsg("dialog.printtofile"));
jfc.setDialogType(JFileChooser.SAVE_DIALOG);
jfc.setSelectedFile(fileDest); jfc.setSelectedFile(fileDest);
int returnVal = jfc.showDialog(this, null); int returnVal = jfc.showDialog(this, null);

View File

@ -337,7 +337,7 @@ sun_jpeg_fill_suspended_buffer(j_decompress_ptr cinfo)
/* Save the data currently in the buffer */ /* Save the data currently in the buffer */
offset = src->pub.bytes_in_buffer; offset = src->pub.bytes_in_buffer;
if (src->pub.next_input_byte > src->inbuf) { if (src->pub.next_input_byte > src->inbuf) {
memcpy(src->inbuf, src->pub.next_input_byte, offset); memmove(src->inbuf, src->pub.next_input_byte, offset);
} }
RELEASE_ARRAYS(env, src); RELEASE_ARRAYS(env, src);
buflen = (*env)->GetArrayLength(env, src->hInputBuffer) - offset; buflen = (*env)->GetArrayLength(env, src->hInputBuffer) - offset;

View File

@ -278,14 +278,26 @@ public class CUPSPrinter {
is); is);
is.close(); is.close();
if (responseMap.length > 0) { if (responseMap != null && responseMap.length > 0) {
defaultMap = responseMap[0]; defaultMap = responseMap[0];
} }
if (defaultMap == null) { if (defaultMap == null) {
os.close(); os.close();
urlConnection.disconnect(); urlConnection.disconnect();
return null;
/* CUPS on OS X, as initially configured, considers the
* default printer to be the last one used that's
* presently available. So if no default was
* reported, exec lpstat -d which has all the Apple
* special behaviour for this built in.
*/
if (UnixPrintServiceLookup.isMac()) {
return UnixPrintServiceLookup.
getDefaultPrinterNameSysV();
} else {
return null;
}
} }
AttributeClass attribClass = (AttributeClass) AttributeClass attribClass = (AttributeClass)

View File

@ -114,6 +114,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
new sun.security.action.GetPropertyAction("os.name")); new sun.security.action.GetPropertyAction("os.name"));
} }
static boolean isMac() {
return osname.startsWith("Mac");
}
static boolean isSysV() { static boolean isSysV() {
return osname.equals("SunOS"); return osname.equals("SunOS");
} }
@ -212,7 +216,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
} }
} }
} else { } else {
if (isSysV()) { if (isMac() || isSysV()) {
printers = getAllPrinterNamesSysV(); printers = getAllPrinterNamesSysV();
} else { //BSD } else { //BSD
printers = getAllPrinterNamesBSD(); printers = getAllPrinterNamesBSD();
@ -361,7 +365,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
if (name == null || name.equals("") || !checkPrinterName(name)) { if (name == null || name.equals("") || !checkPrinterName(name)) {
return null; return null;
} }
if (isSysV()) { if (isMac() || isSysV()) {
printer = getNamedPrinterNameSysV(name); printer = getNamedPrinterNameSysV(name);
} else { } else {
printer = getNamedPrinterNameBSD(name); printer = getNamedPrinterNameBSD(name);
@ -523,7 +527,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
if (CUPSPrinter.isCupsRunning()) { if (CUPSPrinter.isCupsRunning()) {
defaultPrinter = CUPSPrinter.getDefaultPrinter(); defaultPrinter = CUPSPrinter.getDefaultPrinter();
} else { } else {
if (isSysV()) { if (isMac() || isSysV()) {
defaultPrinter = getDefaultPrinterNameSysV(); defaultPrinter = getDefaultPrinterNameSysV();
} else { } else {
defaultPrinter = getDefaultPrinterNameBSD(); defaultPrinter = getDefaultPrinterNameBSD();
@ -644,7 +648,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
return names; return names;
} }
private String getDefaultPrinterNameSysV() { static String getDefaultPrinterNameSysV() {
String defaultPrinter = "lp"; String defaultPrinter = "lp";
String command = "/usr/bin/lpstat -d"; String command = "/usr/bin/lpstat -d";