Permalink
Browse files

Merge branch 'fix-memory-leaks'

  • Loading branch information...
dacap committed May 20, 2015
2 parents 15a227d + a1b9003 commit ec26dd7ee9287d1efe5ac8f867307cf6277f4f79
View
@@ -609,7 +609,7 @@ App::~App()
App::instance()->Exit();
// Finalize modules, configuration and core.
Editor::exitEditorCursor();
Editor::destroyEditorSharedInternals();
boundary_exit();
delete m_legacy;
View
@@ -17,6 +17,12 @@ CmdSequence::CmdSequence()
{
}
CmdSequence::~CmdSequence()
{
for (Cmd* cmd : m_cmds)
delete cmd;
}
void CmdSequence::add(Cmd* cmd)
{
m_cmds.push_back(cmd);
View
@@ -18,6 +18,7 @@ namespace app {
class CmdSequence : public Cmd {
public:
CmdSequence();
~CmdSequence();
void add(Cmd* cmd);
View
@@ -46,7 +46,6 @@ using namespace doc;
Document::Document(Sprite* sprite)
: m_undo(new DocumentUndo)
, m_associated_to_file(false)
, m_mutex(new mutex)
, m_write_lock(false)
, m_read_locks(0)
// Information about the file format used to load/save this document
@@ -515,7 +514,7 @@ bool Document::lock(LockType lockType, int timeout)
{
while (timeout >= 0) {
{
scoped_lock lock(*m_mutex);
scoped_lock lock(m_mutex);
switch (lockType) {
case ReadLock:
@@ -560,7 +559,7 @@ bool Document::lockToWrite(int timeout)
{
while (timeout >= 0) {
{
scoped_lock lock(*m_mutex);
scoped_lock lock(m_mutex);
// this only is possible if there are just one reader
if (m_read_locks == 1) {
ASSERT(!m_write_lock);
@@ -589,7 +588,7 @@ bool Document::lockToWrite(int timeout)
void Document::unlockToRead()
{
scoped_lock lock(*m_mutex);
scoped_lock lock(m_mutex);
ASSERT(m_read_locks == 0);
ASSERT(m_write_lock);
@@ -600,7 +599,7 @@ void Document::unlockToRead()
void Document::unlock()
{
scoped_lock lock(*m_mutex);
scoped_lock lock(m_mutex);
if (m_write_lock) {
m_write_lock = false;
View
@@ -11,6 +11,7 @@
#include "app/file/format_options.h"
#include "base/disable_copying.h"
#include "base/mutex.h"
#include "base/observable.h"
#include "base/shared_ptr.h"
#include "base/unique_ptr.h"
@@ -25,10 +26,6 @@
#include <string>
namespace base {
class mutex;
}
namespace doc {
class Cel;
class Layer;
@@ -201,7 +198,7 @@ namespace app {
} m_bound;
// Mutex to modify the 'locked' flag.
base::mutex* m_mutex;
base::mutex m_mutex;
// True if some thread is writing the sprite.
bool m_write_lock;
View
@@ -30,6 +30,7 @@
#include "app/ui/color_spectrum.h"
#include "app/ui/editor/editor.h"
#include "app/ui/input_chain.h"
#include "app/ui/palette_popup.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/status_bar.h"
#include "app/ui_context.h"
@@ -323,15 +324,18 @@ void ColorBar::onPaletteButtonClick()
}
case PalButton::PRESETS: {
if (!m_palettePopup.isVisible()) {
if (!m_palettePopup)
m_palettePopup.reset(new PalettePopup());
if (!m_palettePopup->isVisible()) {
gfx::Rect bounds = m_buttons.getItem(item)->getBounds();
m_palettePopup.showPopup(
m_palettePopup->showPopup(
gfx::Rect(bounds.x, bounds.y+bounds.h,
ui::display_w()/2, ui::display_h()/2));
}
else {
m_palettePopup.closeWindow(NULL);
m_palettePopup->closeWindow(NULL);
}
break;
}
View
@@ -13,7 +13,6 @@
#include "app/ui/button_set.h"
#include "app/ui/color_button.h"
#include "app/ui/input_chain_element.h"
#include "app/ui/palette_popup.h"
#include "app/ui/palette_view.h"
#include "base/connection.h"
#include "base/signal.h"
@@ -28,8 +27,9 @@
namespace app {
class ColorButton;
class Command;
class PalettesLoader;
class PaletteIndexChangeEvent;
class PalettePopup;
class PalettesLoader;
class ColorBar : public ui::Box
, public PaletteViewDelegate
@@ -109,7 +109,7 @@ namespace app {
};
ButtonSet m_buttons;
PalettePopup m_palettePopup;
base::UniquePtr<PalettePopup> m_palettePopup;
ScrollableView m_scrollableView;
PaletteView m_paletteView;
ui::Button m_remapButton;
@@ -201,6 +201,12 @@ Editor::~Editor()
m_mask_timer.stop();
}
void Editor::destroyEditorSharedInternals()
{
m_renderBuffer.reset();
exitEditorCursor();
}
bool Editor::isActive() const
{
return (current_editor == this);
@@ -80,6 +80,8 @@ namespace app {
Editor(Document* document, EditorFlags flags = kDefaultEditorFlags);
~Editor();
static void destroyEditorSharedInternals();
bool isActive() const;
DocumentView* getDocumentView() { return m_docView; }
@@ -208,7 +210,6 @@ namespace app {
// in cursor.cpp
static void initEditorCursor();
static void exitEditorCursor();
protected:
bool onProcessMessage(ui::Message* msg) override;
@@ -221,6 +222,7 @@ namespace app {
void onExposeSpritePixels(doc::DocumentEvent& ev);
private:
static void exitEditorCursor();
void setStateInternal(const EditorStatePtr& newState);
void updateQuicktool();
void updateContextBarFromModifiers();
@@ -298,7 +298,10 @@ SkinTheme::~SkinTheme()
m_parts_by_id.clear();
sheet_mapping.clear();
// Destroy the minifont
// Destroy fonts
if (m_defaultFont)
m_defaultFont->dispose();
if (m_miniFont)
m_miniFont->dispose();
}
View
@@ -84,3 +84,7 @@ if(WIN32)
endif()
add_library(base-lib ${BASE_SOURCES})
if(ENABLE_MEMLEAK AND MSVC)
target_link_libraries(base-lib dbghelp)
endif()
View
@@ -30,7 +30,10 @@ class Signal0_base : public Signal {
typedef std::vector<SlotType*> SlotList;
Signal0_base() { }
~Signal0_base() { }
~Signal0_base() {
for (SlotType* slot : m_slots)
delete slot;
}
Signal0_base(const Signal0_base&) { }
Signal0_base operator=(const Signal0_base&) {
@@ -127,7 +130,10 @@ class Signal1_base : public Signal {
typedef std::vector<SlotType*> SlotList;
Signal1_base() { }
~Signal1_base() { }
~Signal1_base() {
for (SlotType* slot : m_slots)
delete slot;
}
Signal1_base(const Signal1_base&) { }
Signal1_base operator=(const Signal1_base&) {
@@ -225,7 +231,10 @@ class Signal2_base : public Signal {
typedef std::vector<SlotType*> SlotList;
Signal2_base() { }
~Signal2_base() { }
~Signal2_base() {
for (SlotType* slot : m_slots)
delete slot;
}
Signal2_base(const Signal2_base&) { }
Signal2_base operator=(const Signal2_base&) {
@@ -82,11 +82,10 @@ void UndoHistory::clearRedo()
void UndoHistory::add(UndoCommand* cmd)
{
UndoState* state = new UndoState;
UndoState* state = new UndoState(cmd);
state->m_prev = m_last;
state->m_next = nullptr;
state->m_parent = m_cur;
state->m_cmd = cmd;
if (!m_first)
m_first = state;
View
@@ -8,6 +8,8 @@
#define UNDO_UNDO_STATE_H_INCLUDED
#pragma once
#include "undo/undo_command.h"
namespace undo {
class UndoCommand;
@@ -18,6 +20,15 @@ namespace undo {
class UndoState {
friend class UndoHistory;
public:
UndoState(UndoCommand* cmd)
: m_prev(nullptr)
, m_next(nullptr)
, m_parent(nullptr)
, m_cmd(cmd) {
}
~UndoState() {
delete m_cmd;
}
UndoState* prev() const { return m_prev; }
UndoState* next() const { return m_next; }
UndoCommand* cmd() const { return m_cmd; }

0 comments on commit ec26dd7

Please sign in to comment.