When the cups server u access doesnt have rights for you to access, impress and writer 
crashes

Impress Crashes with the following stack trace.
In the code, when  the warning dialog is made silent or if the option like "Fit to Window" is selected
in the print dialog, then it works properly.

It basically crashes from  the Execute of  AbstractSdPrintDlg_Impl which inherits ModalDialog.
Writer too crashes the sameway in ImplPrnDlgUpdatePrinter.

#0  0x40e77f13 in osl_incrementInterlockedCount () from ./libuno_sal.so.3
#1  0x40b7f1c0 in String::Assign () from ./libtl680li.so
#2  0x40230a4e in String::operator= (this=0xbfffdc20, rStr=@0x496ff6a4) at string.hxx:541
#3  0x4085c06a in ImplPrnDlgUpdatePrinter (pPrinter=0x496ff588, pTempPrinter=0x0)
    at /root/cvs/m79/ooo-build/build/src680-m79/svtools/source/dialogs/prnsetup.cxx:157
#4  0x4086346e in PrintDialog::DataChanged () from ./libsvt680li.so
#5  0x4033793c in Window::NotifyAllChilds () from ./libvcl680li.so
#6  0x4016f599 in Application::NotifyAllWindows () from ./libvcl680li.so
#7  0x403497a9 in ImplHandleSalSettings () from ./libvcl680li.so
#8  0x40349e95 in ImplWindowFrameProc () from ./libvcl680li.so
#9  0x4239c12b in SalDisplay::DispatchInternalEvent () from ./libvclplug_gen680li.so
#10 0x41e8d852 in GtkXLib::userEventFn () from ./libvclplug_gtk680li.so
#11 0x422c9221 in g_idle_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#12 0x422cae87 in g_main_context_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#13 0x422cd5c7 in g_main_context_iterate () from /opt/gnome/lib/libglib-2.0.so.0
#14 0x422cd6c3 in g_main_context_iteration () from /opt/gnome/lib/libglib-2.0.so.0
#15 0x41e8d9e2 in GtkXLib::Yield () from ./libvclplug_gtk680li.so
#16 0x423a062f in X11SalInstance::Yield () from ./libvclplug_gen680li.so
#17 0x4016ed62 in Application::Yield () from ./libvcl680li.so
#18 0x402d56e0 in Dialog::Execute () from ./libvcl680li.so
#19 0x46e9a8cb in AbstractSdPrintDlg_Impl::Execute (this=0x48c87e40)
    at /root/cvs/m79/ooo-build/build/src680-m79/sd/source/ui/dlg/sddlgfact.cxx:139
#20 0x46ab5b5b in sd::PrintManager::FitPageToPrinterWithDialog (this=0x44be6e88, pPrinter=0x470c5eb0, bSilent=false)
    at /root/cvs/m79/ooo-build/build/src680-m79/sd/source/ui/view/PrintManager.cxx:775
#21 0x46ab5454 in sd::PrintManager::DoPrint (this=0x44be6e88, pPrinter=0x470c5eb0, pPrintDialog=0x49898b10, bSilent=0 '\0')
    at /root/cvs/m79/ooo-build/build/src680-m79/sd/source/ui/view/PrintManager.cxx:578
#22 0x46ab8895 in sd::ViewShellBase::DoPrint () from ./libsd680li.so
#23 0x440873cd in SfxViewShell::ExecPrint_Impl () from ./libsfx680li.so
#24 0x4406ffd4 in SfxStubSfxViewShellExecPrint_Impl () from ./libsfx680li.so
#25 0x440b68f3 in SfxDispatcher::Call_Impl () from ./libsfx680li.so
#26 0x440b9159 in SfxDispatcher::PostMsgHandler () from ./libsfx680li.so
#27 0x440b906e in SfxDispatcher::LinkStubPostMsgHandler () from ./libsfx680li.so
#28 0x440dc2ee in SfxHintPoster::Event () from ./libsfx680li.so
#29 0x440dc299 in SfxHintPoster::LinkStubDoEvent_Impl () from ./libsfx680li.so
#30 0x4034936f in ImplHandleUserEvent () from ./libvcl680li.so
#31 0x40349e9f in ImplWindowFrameProc () from ./libvcl680li.so
#32 0x4239c12b in SalDisplay::DispatchInternalEvent () from ./libvclplug_gen680li.so
#33 0x41e8d852 in GtkXLib::userEventFn () from ./libvclplug_gtk680li.so
#34 0x422c9221 in g_idle_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#35 0x422cae87 in g_main_context_dispatch () from /opt/gnome/lib/libglib-2.0.so.0
#36 0x422cd5c7 in g_main_context_iterate () from /opt/gnome/lib/libglib-2.0.so.0


Solution:

there is SfxPrinter *mpPrinter pointer which is bogus. It means, that this is freed
and later the same thing is used.

>> SNIP
Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter )
{
        XubString aPrnName;
        if ( pTempPrinter )
                aPrnName = pTempPrinter->GetName();
        else
                aPrnName = pPrinter->GetName(); /* CRASHES HERE BECAUSE pPrinter is bogus */
                                                                                                                             
        BOOL    bFound = FALSE;
<< SNIP

So this pPrinter which is of SfxPrinter * is freed somewhere.
SfxPrinter is inherited from Printer (vcl/source/gdi/print.cxx)

>>SNIP

// class SfxPrinter ------------------------------------------------------
                                                                                                                             
class SFX2_DLLPUBLIC SfxPrinter : public Printer
{
private:
        JobSetup                                aOrigJobSetup;
        SfxItemSet*                             pOptions;
        SfxPrinter_Impl*                pImpl;
        BOOL                                    bKnown;
                                                                                                                             

<<SNIP

So putting a break point into Printer::~Printer() at vcl/source/gdi/print.cxx

>>SNIP
Printer::~Printer()
{
        DBG_ASSERT( !IsPrinting(), "Printer::~Printer() - Job is printing" );
        DBG_ASSERT( !IsJobActive(), "Printer::~Printer() - Job is active" );
        DBG_ASSERT( !mpQPrinter, "Printer::~Printer() - QueuePrinter not destroyed" );
        DBG_ASSERT( !mpQMtf, "Printer::~Printer() - QueueMetafile not destroyed" );
                                                                                                                             
    delete mpPrinterOptions;
                                                                                                                           
<<SNIP

It reveals that it is freed from 

sfx2/source/view/viewprn.cxx +348 is the place where it frees at
SfxPrinter* SfxViewShell::SetPrinter_Impl( SfxPrinter *pNewPrinter )

>>SNIP

        if ( aNewJobSetup != aOldJobSetup )
        {
            // JobSetup hat sich geaendert (=> App mu\s neu formatieren)
            // pDocPrinter->SetOrigJobSetup( aNewJobSetup );
            nChangedFlags |= SFX_PRINTER_JOBSETUP;
        }
                                                                                                                             
        // alten, ver"anderten Printer behalten
        pDocPrinter->SetPrinterProps( pNewPrinter );
        delete pNewPrinter; // FREED FROM HERE.
        }
                                                                                                                             
        if ( 0 != nChangedFlags )
        // SetPrinter will delete the old printer if it changes
        SetPrinter( pDocPrinter, nChangedFlags );
        return pDocPrinter;
<<SNIP

Going slightly up the stack to its caller 
SfxViewShell::ExecPrint_Impl at sfx2/source/view/viewprn.cxx +366
I came to the conclusion, that the pointer is freed. But used later

Lemme explain:

>>SNIP
               // if no arguments are given, retrieve them from a dialog
                if ( !bIsAPI )
                        {
                    // PrinterDialog needs a temporary printer
                                SfxPrinter* pDlgPrinter = pPrinter->Clone();
                                nDialogRet = 0;
                                if ( SID_PRINTDOC == nId )
                                {
<<SNIP.

In the above function pDlgPrinter is cloned from pPrinter.

>>SNIP
                                // set printer on dialog and execute
                                                pPrintDlg->SetPrinter( pDlgPrinter );
                                ::DisableRanges( *pPrintDlg, pDlgPrinter );
                                                nDialogRet = pPrintDlg->Execute();
<<SNIP

That cloned pointer is set as the printer to pPrintDlg <NOTE THIS POINT !!!>
and the window is executed.

>>SNIP
                        // take the changes made in the dialog
                                        pPrinter = SetPrinter_Impl( pDlgPrinter );
                                                                                                                             
                        // forget new printer, it was taken over (as pPrinter) or deleted
                        pDlgPrinter = NULL;

<<SNIP
This code frees pDlgPrinter inside the function SetPrinter_Impl which is the place
the pointer is freed as explained above.

But remember though the pDlgPrinter is freed and NULLed, but the pPrintDlg still points
to the freed location of pDlgPrinter.

>>SNIP
               if ( bDontModifyDoc && bOldFlag != pObjSh->IsEnableSetModified() )
                    pObjSh->EnableSetModified( bOldFlag );
                                                                                                                             
                        GetObjectShell()->Broadcast( SfxPrintingHint( -1, pPrintDlg, pPrinter ) );
                        ErrCode nError = DoPrint( pPrinter, pPrintDlg, bSilent );
                        if ( nError == PRINTER_OK )
                        {

<<SNIP

At this place still pPrintDlg points to the pDlgPrinter freed location, which on exec
crashes.

Now i added 

>>SNIP

                        // take the changes made in the dialog
                                        pPrinter = SetPrinter_Impl( pDlgPrinter );
                                                                                                                             
                        // forget new printer, it was taken over (as pPrinter) or deleted
                        pDlgPrinter = NULL;
                        /* Now lets reset the Dialog printer, since its freed */
                        pPrintDlg->SetPrinter (pPrinter);
                                                                                                                             
    
<<SNIP

which should solve the problem



