Fixed some memory leak handling and the text tool

fixes #806
presentation
Andreas Butti 7 years ago
parent a0844a03a4
commit 68f4c51417
  1. 39
      src/gui/PageView.cpp
  2. 12
      src/gui/PageView.h
  3. 31
      src/util/audio/DeviceInfo.cpp
  4. 11
      src/util/audio/DeviceInfo.h

@ -63,26 +63,14 @@ XojPageView::XojPageView(XournalView* xournal, PageRef page)
this->rerenderComplete = false;
g_mutex_init(&this->repaintRectMutex);
this->crBuffer = NULL;
this->inEraser = false;
this->verticalSpace = NULL;
this->selection = NULL;
this->textEditor = NULL;
// this does not have to be deleted afterwards:
// (we need it for undo commands)
this->oldtext = NULL;
this->search = NULL;
this->eraser = new EraseHandler(xournal->getControl()->getUndoRedoHandler(), xournal->getControl()->getDocument(),
this->page, xournal->getControl()->getToolHandler(), this);
this->inputHandler = NULL;
}
XojPageView::~XojPageView()
@ -257,6 +245,20 @@ void XojPageView::startText(double x, double y)
this->xournal->endTextAllPages(this);
this->xournal->getControl()->getSearchBar()->showSearchBar(false);
if (this->textEditor != NULL)
{
Text* text = this->textEditor->getText();
GdkRectangle matchRect = {gint(x - 10), gint(y - 10), 20, 20};
if (!text->intersectsArea(&matchRect))
{
endText();
}
else
{
this->textEditor->mousePressed(x - text->getX(), y - text->getY());
}
}
if (this->textEditor == NULL)
{
// Is there already a textfield?
@ -316,19 +318,6 @@ void XojPageView::startText(double x, double y)
this->rerenderPage();
}
else
{
Text* text = this->textEditor->getText();
GdkRectangle matchRect = {gint(x - 10), gint(y - 10), 20, 20};
if (!text->intersectsArea(&matchRect))
{
endText();
}
else
{
this->textEditor->mousePressed(x - text->getX(), y - text->getY());
}
}
}
bool XojPageView::onButtonPressEvent(const PositionInputData& pos)

@ -179,17 +179,17 @@ private:
XournalView* xournal;
Settings* settings;
EraseHandler* eraser;
InputHandler* inputHandler;
InputHandler* inputHandler = nullptr;
/**
* The selected (while selection)
*/
Selection* selection;
Selection* selection = nullptr;
/**
* The text editor View
*/
TextEditor* textEditor;
TextEditor* textEditor = nullptr;
/**
* For keeping old text changes to undo!
@ -198,19 +198,19 @@ private:
bool selected;
cairo_surface_t* crBuffer;
cairo_surface_t* crBuffer = nullptr;
bool inEraser;
/**
* Vertical Space
*/
VerticalToolHandler* verticalSpace;
VerticalToolHandler* verticalSpace = nullptr;
/**
* Search handling
*/
SearchControl* search;
SearchControl* search = nullptr;
/**
* Unixtimestam when the page was last time in the visible area

@ -1,14 +1,25 @@
#include "DeviceInfo.h"
DeviceInfo::DeviceInfo(portaudio::Device *device, bool selected) : deviceName(device->name()),
index(device->index()),
selected(selected),
inputChannels((device->isFullDuplexDevice() || device->isInputOnlyDevice()) ? device->maxInputChannels() : 0),
outputChannels((device->isFullDuplexDevice() || device->isOutputOnlyDevice()) ? device->maxOutputChannels() : 0)
DeviceInfo::DeviceInfo(portaudio::Device *device, bool selected)
: deviceName(device->name()),
index(device->index()),
selected(selected),
inputChannels((device->isFullDuplexDevice() || device->isInputOnlyDevice()) ? device->maxInputChannels() : 0),
outputChannels((device->isFullDuplexDevice() || device->isOutputOnlyDevice()) ? device->maxOutputChannels() : 0)
{
XOJ_INIT_TYPE(DeviceInfo);
}
DeviceInfo::DeviceInfo(const DeviceInfo& other)
: deviceName(other.deviceName),
index(other.index),
selected(other.selected),
inputChannels(other.inputChannels),
outputChannels(other.outputChannels)
{
XOJ_INIT_TYPE(DeviceInfo);
}
DeviceInfo::~DeviceInfo()
{
XOJ_CHECK_TYPE(DeviceInfo);
@ -16,23 +27,31 @@ DeviceInfo::~DeviceInfo()
XOJ_RELEASE_TYPE(DeviceInfo);
}
const string &DeviceInfo::getDeviceName() const
const string& DeviceInfo::getDeviceName() const
{
XOJ_CHECK_TYPE(DeviceInfo);
return deviceName;
}
const PaDeviceIndex DeviceInfo::getIndex() const
{
XOJ_CHECK_TYPE(DeviceInfo);
return index;
}
const bool DeviceInfo::getSelected() const
{
XOJ_CHECK_TYPE(DeviceInfo);
return selected;
}
const int DeviceInfo::getInputChannels() const
{
XOJ_CHECK_TYPE(DeviceInfo);
return inputChannels;
}

@ -17,24 +17,25 @@
class DeviceInfo
{
public:
DeviceInfo(portaudio::Device *device, bool selected);
DeviceInfo(portaudio::Device *device, bool selected);
DeviceInfo(const DeviceInfo& other);
~DeviceInfo();
const string &getDeviceName() const;
public:
const string& getDeviceName() const;
const PaDeviceIndex getIndex() const;
const bool getSelected() const;
const int getInputChannels() const;
const int getOutputChannels() const;
private:
XOJ_TYPE_ATTRIB;
const std::string deviceName;
const PaDeviceIndex index;
const bool selected;
const int inputChannels;
const int outputChannels;
private:
XOJ_TYPE_ATTRIB;
};

Loading…
Cancel
Save