[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: New KDE printing system
From:       Michael Goffioul <goffioul () imec ! be>
Date:       2001-02-28 15:50:19
[Download RAW message or body]

> Hmmm, I got another thought:
> When providing a pointer to the object, you have to state explicidly, that
> one mustn't delete the pointer.
> How about handing a reference like
>
> static KPrinter &self()
> {
>         return KPrinterFactory::self()->printer();
> }
>
> makes deleting the object a bit less likely.

The problem of deleting is double: the factory doesn't know the object has
been deleted, and all settings are lost. The first problem can be solved by
adding code in KPrinter destructor to tell the factory the object is deleted.
But the most important thing is that user settings are lost: imagine setting
the same options each time you want to print... Then why not save the
KPrinter state ? Answer: why not keep the KPrinter object ? Qt solves this
by having a static QPrintDialog object. I am solving this by having a factory
(singleton) which is responsible for KPrinter creation and deletion.

Michael.

--
------------------------------------------------------------------
Michael Goffioul                IMEC-DESICS-MIRA
e-mail: goffioul@imec.be        (Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510          Kapeldreef, 75
Fax:    +32/16/28-1515          3001 HEVERLEE, BELGIUM
------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic