diff --git a/src/gui/PageView.cpp b/src/gui/PageView.cpp index 3d9a73bd..f0fdc568 100644 --- a/src/gui/PageView.cpp +++ b/src/gui/PageView.cpp @@ -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) diff --git a/src/gui/PageView.h b/src/gui/PageView.h index 54d1a08f..5ee68e01 100644 --- a/src/gui/PageView.h +++ b/src/gui/PageView.h @@ -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 diff --git a/src/util/audio/DeviceInfo.cpp b/src/util/audio/DeviceInfo.cpp index add44cb7..79dad2ce 100644 --- a/src/util/audio/DeviceInfo.cpp +++ b/src/util/audio/DeviceInfo.cpp @@ -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; } diff --git a/src/util/audio/DeviceInfo.h b/src/util/audio/DeviceInfo.h index a14f94fb..04a9b37a 100644 --- a/src/util/audio/DeviceInfo.h +++ b/src/util/audio/DeviceInfo.h @@ -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; };