r18847 - gnucash/trunk/src/gnc - Cutecash: Remove QSharedPointer because manual delete is sufficient.

Christian Stimming cstim at code.gnucash.org
Fri Mar 5 15:46:35 EST 2010


Author: cstim
Date: 2010-03-05 15:46:35 -0500 (Fri, 05 Mar 2010)
New Revision: 18847
Trac: http://svn.gnucash.org/trac/changeset/18847

Removed:
   gnucash/trunk/src/gnc/ScopedPointer.hpp
Modified:
   gnucash/trunk/src/gnc/mainwindow.cpp
   gnucash/trunk/src/gnc/mainwindow.hpp
Log:
Cutecash: Remove QSharedPointer because manual delete is sufficient.

Also, the QSharedPointer cannot be used for bookkeeping of a C pointer
to any gnucash object because it refuses to work if it doesn't know the
actual struct definition, which in gnucash is always private. The
boost::shared_ptr would work without (by the custom deleter argument in the
constructor), but QSharedPointer doesn't (the custom deleter is accepted
only in addition to the known storage size, not alternatively), so it is
pointless here.

Deleted: gnucash/trunk/src/gnc/ScopedPointer.hpp
===================================================================
--- gnucash/trunk/src/gnc/ScopedPointer.hpp	2010-03-05 20:41:40 UTC (rev 18846)
+++ gnucash/trunk/src/gnc/ScopedPointer.hpp	2010-03-05 20:46:35 UTC (rev 18847)
@@ -1,106 +0,0 @@
-/*
- * ScopedPointer.hpp
- * Copyright (C) 2010 Christian Stimming
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_SCOPEDPOINTER_HPP
-#define GNC_SCOPEDPOINTER_HPP
-
-#error "This file requires the Boost library because the boost::shared_ptr is nice and has non-trivial features. However, in the current build this file isn't used anyway, so it should not be used within this project so far."
-#include <boost/shared_ptr.hpp>
-
-namespace gnc
-{
-
-/** A sole ownership of a single C object.
- *
- * This copies the interface of the boost::scoped_ptr, but with the
- * boost::shared_ptr possiblity of a custom deleter function because
- * we need that.
- */
-template<class T>
-class ScopedPointer // noncopyable
-{
-    // Private copy constructor so that this is noncopyable
-    ScopedPointer(ScopedPointer const &);
-    ScopedPointer& operator=(ScopedPointer const&);
-    void operator==(ScopedPointer const&) const;
-    void operator!=(ScopedPointer const&) const;
-    boost::shared_ptr<T> m_ptr;
-    typedef ScopedPointer<T> this_type;
-public:
-    typedef T element_type;
-
-    ScopedPointer()
-            : m_ptr()
-    { }
-
-    template<class Y, class D> ScopedPointer(Y * ptr, D deleter)
-            : m_ptr(ptr, deleter)
-    { }
-
-    void reset() // never throws in 1.30+
-    {
-        this_type().swap(*this);
-    }
-
-    template<class Y, class D> void reset( Y * p, D d )
-    {
-        this_type( p, d ).swap( *this );
-    }
-
-    T & operator*() const // never throws
-    {
-        assert(m_ptr != 0);
-        return *m_ptr.get();
-    }
-
-    T * operator->() const // never throws
-    {
-        assert(m_ptr != 0);
-        return m_ptr.get();
-    }
-
-    T * get() const // never throws
-    {
-        return m_ptr.get();
-    }
-
-    // implicit conversion to "bool"
-    typedef T * (this_type::*unspecified_bool_type)() const;
-    operator unspecified_bool_type() const // never throws
-    {
-        return m_ptr == 0 ? 0 : &this_type::get;
-    }
-
-    bool operator! () const // never throws
-    {
-        return m_ptr == 0;
-    }
-
-    void swap(ScopedPointer & other) // never throws
-    {
-        m_ptr.swap(other.m_ptr);
-    }
-};
-
-} // END namespace gnc
-
-#endif

Modified: gnucash/trunk/src/gnc/mainwindow.cpp
===================================================================
--- gnucash/trunk/src/gnc/mainwindow.cpp	2010-03-05 20:41:40 UTC (rev 18846)
+++ gnucash/trunk/src/gnc/mainwindow.cpp	2010-03-05 20:46:35 UTC (rev 18847)
@@ -83,6 +83,7 @@
 
 MainWindow::~MainWindow()
 {
+    delete ui;
     if (m_session.get())
     {
         qof_session_destroy(m_session.get());

Modified: gnucash/trunk/src/gnc/mainwindow.hpp
===================================================================
--- gnucash/trunk/src/gnc/mainwindow.hpp	2010-03-05 20:41:40 UTC (rev 18846)
+++ gnucash/trunk/src/gnc/mainwindow.hpp	2010-03-05 20:46:35 UTC (rev 18847)
@@ -24,7 +24,6 @@
 #define MAINWINDOW_H
 
 #include <QMainWindow>
-#include <QSharedPointer>
 #include "gnc/Session.hpp"
 #include "gnc/AccountItemModel.hpp"
 
@@ -76,7 +75,7 @@
     void setCurrentFile(const QString &fileName);
     QString strippedName(const QString &fullFileName);
 
-    QSharedPointer<Ui::MainWindow> ui;
+    Ui::MainWindow *ui;
 
     QString curFile;
 



More information about the gnucash-changes mailing list