Object not deleted in main/qc_applicationwindow.cpp

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Object not deleted in main/qc_applicationwindow.cpp

ClaudeQC

Hello,

- In main/qc_applicationwindow.cpp, in the following function:
        slotFileExport( const QString& name, const QString& format,
                        QSize size, bool black, bool bw)

  The "painter" object is not deleted at the end of the export process.
 
- Code look like below:

    // GraphicView deletes painter
    painter->end();
    delete buffer;

- Should it be like:

    // GraphicView deletes painter
    painter->end();
    delete painter;
    delete buffer;


Claude

Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

R. van Twisk
Administrator
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

R. van Twisk
Administrator
In reply to this post by ClaudeQC
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

ClaudeQC

On 24/07/2011 09:15, R. van Twisk [via LibreCAD] wrote:

 > Claude,
 >
 > what if we just do it like this??
 > This way we don't have to worry about deleting the painter at all.
 >

Hello Ries,

- I don't like creating objects in the stack.
   Prefer to create them in the heap memory (with new).

- I don't know RS_PainterQt class.
   If this class is not too big in term of data memory usage, it may be
   acceptable to create associated objects in the stack.


Claude


Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

R. van Twisk
Administrator
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

R. van Twisk
Administrator
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

ClaudeQC

On 24/07/2011 13:54, R. van Twisk [via LibreCAD] wrote:

 >
 >
 > I just asked this question on the IRC channel and they mentioned 'stack' :)
 >
 > For this case, I think I need to agree with that. The QPainter is just used in
 > that function and doesn't use any memory anyways.
 >

- Ok.

- Given your explanation, I agreed with you to create these objects
   from the stack.


Claude


Reply | Threaded
Open this post in threaded view
|

Re: Object not deleted in main/qc_applicationwindow.cpp

R. van Twisk
Administrator
CONTENTS DELETED
The author has deleted this message.