From d6a0ecd174e57e87cbba4707110047559deeee76 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Fri, 5 Mar 2010 20:46:35 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18847 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnc/ScopedPointer.hpp | 106 -------------------------------------- src/gnc/mainwindow.cpp | 1 + src/gnc/mainwindow.hpp | 3 +- 3 files changed, 2 insertions(+), 108 deletions(-) delete mode 100644 src/gnc/ScopedPointer.hpp diff --git a/src/gnc/ScopedPointer.hpp b/src/gnc/ScopedPointer.hpp deleted file mode 100644 index 21d23d80ff..0000000000 --- a/src/gnc/ScopedPointer.hpp +++ /dev/null @@ -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@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 - -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 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 m_ptr; - typedef ScopedPointer this_type; -public: - typedef T element_type; - - ScopedPointer() - : m_ptr() - { } - - template ScopedPointer(Y * ptr, D deleter) - : m_ptr(ptr, deleter) - { } - - void reset() // never throws in 1.30+ - { - this_type().swap(*this); - } - - template 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 diff --git a/src/gnc/mainwindow.cpp b/src/gnc/mainwindow.cpp index 09bd101a00..ff14150049 100644 --- a/src/gnc/mainwindow.cpp +++ b/src/gnc/mainwindow.cpp @@ -83,6 +83,7 @@ MainWindow::MainWindow() MainWindow::~MainWindow() { + delete ui; if (m_session.get()) { qof_session_destroy(m_session.get()); diff --git a/src/gnc/mainwindow.hpp b/src/gnc/mainwindow.hpp index d11f6ff9a9..7808cd6bc4 100644 --- a/src/gnc/mainwindow.hpp +++ b/src/gnc/mainwindow.hpp @@ -24,7 +24,6 @@ #define MAINWINDOW_H #include -#include #include "gnc/Session.hpp" #include "gnc/AccountItemModel.hpp" @@ -76,7 +75,7 @@ private: void setCurrentFile(const QString &fileName); QString strippedName(const QString &fullFileName); - QSharedPointer ui; + Ui::MainWindow *ui; QString curFile;