]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied [ 872574 ] fix of fatal error of preview without printer
authorJulian Smart <julian@anthemion.co.uk>
Thu, 8 Jan 2004 08:29:59 +0000 (08:29 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 8 Jan 2004 08:29:59 +0000 (08:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25090 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/docview.cpp
src/msw/dcprint.cpp

index 8e8c012701cc96f1427ad2c964883fdb6ce88bce..65e74723ad97b12bcc4d11c8db09d6aa280ecf74 100644 (file)
@@ -953,6 +953,12 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
     {
         // Pass two printout objects: for preview, and possible printing.
         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));
index f277ca44b823766f5ac602c851e4ef6613bc30cc..53542de5ea305ad0c257f2203b31f4ecaab0601c 100644 (file)
@@ -309,15 +309,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();
     }