diff --git a/src/common/docview.cpp b/src/common/docview.cpp index b67efc1a2c..eb6ea86b4d 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -920,8 +920,13 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event)) if (printout) { // Pass two printout objects: for preview, and possible printing. - wxPrintPreviewBase *preview = (wxPrintPreviewBase *) NULL; - preview = new wxPrintPreview(printout, view->OnCreatePrintout()); + wxPrintPreviewBase *preview = new wxPrintPreview(printout, view->OnCreatePrintout()); + if ( !preview->Ok() ) + { + delete preview; + wxMessageBox( _("Sorry, print preview needs a printer to be installed.") ); + return; + } wxPreviewFrame *frame = new wxPreviewFrame(preview, (wxFrame *)wxTheApp->GetTopWindow(), _("Print Preview"), wxPoint(100, 100), wxSize(600, 650)); diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 07c5a86513..93c204e8f2 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -383,14 +383,10 @@ WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) { // Retrieve the default device name wxString portName; -#ifdef __WXDEBUG__ - bool ret = -#else // !Debug - (void) -#endif // Debug/Release - wxGetDefaultDeviceName(devNameStr, portName); - - wxASSERT_MSG( ret, wxT("Could not get default device name.") ); + if (!wxGetDefaultDeviceName(devNameStr, portName)) + { + return 0; // Could not get default device name + } deviceName = devNameStr.c_str(); }