From e1dcb397d595c110faadaae6bab861bae97717b8 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Fri, 26 Sep 2014 19:49:14 -0700 Subject: [PATCH] Crash in print spooler if save to PDF selected early. The first issue is that the save to pdf button is enabled before the first layout completed and at this point we do not know anything about the document. The second is that if a layout is in progress and we select save to pdf we end up starting the documents UI twice and finishing the second instance carshes the spooler. bug:17676878 Change-Id: Id0b1f06e4d377347286c2dde09669d431441234b --- .../src/com/android/printspooler/ui/PrintActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index aa42c7524ca9b..0a01c74d31c3f 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -566,6 +566,9 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat } private void startCreateDocumentActivity() { + if (!isResumed()) { + return; + } PrintDocumentInfo info = mPrintedDocument.getDocumentInfo().info; if (info == null) { return; @@ -1347,7 +1350,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPrintButton.setImageResource(R.drawable.ic_menu_savetopdf); mPrintButton.setContentDescription(getString(R.string.savetopdf_button)); } - if ((mRangeOptionsSpinner.getSelectedItemPosition() == 1 + if (!mPrintedDocument.getDocumentInfo().laidout + ||(mRangeOptionsSpinner.getSelectedItemPosition() == 1 && (TextUtils.isEmpty(mPageRangeEditText.getText()) || hasErrors())) || (mRangeOptionsSpinner.getSelectedItemPosition() == 0 && (mPrintedDocument.getDocumentInfo() == null || hasErrors()))) {