aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/PlatCocoa.h3
-rw-r--r--cocoa/PlatCocoa.mm10
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp31
-rw-r--r--qt/ScintillaEditBase/PlatQt.h2
-rw-r--r--win32/PlatWin.cxx18
5 files changed, 45 insertions, 19 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index 8a47e7302..d6f2bf449 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -63,6 +63,9 @@ private:
static const int BITS_PER_COMPONENT = 8;
static const int BITS_PER_PIXEL = BITS_PER_COMPONENT * 4;
static const int BYTES_PER_PIXEL = BITS_PER_PIXEL / 8;
+
+ void Clear();
+
public:
SurfaceImpl();
~SurfaceImpl() override;
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index c89a6f3aa..9c4d6a340 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -146,12 +146,12 @@ SurfaceImpl::SurfaceImpl() {
//--------------------------------------------------------------------------------------------------
SurfaceImpl::~SurfaceImpl() {
- Release();
+ Clear();
}
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::Release() {
+void SurfaceImpl::Clear() {
textLayout->setContext(nullptr);
if (bitmapData) {
bitmapData.reset();
@@ -169,6 +169,12 @@ void SurfaceImpl::Release() {
//--------------------------------------------------------------------------------------------------
+void SurfaceImpl::Release() {
+ Clear();
+}
+
+//--------------------------------------------------------------------------------------------------
+
bool SurfaceImpl::Initialised() {
// We are initalised if the graphics context is not null
return gc != NULL;// || port != NULL;
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index 87496a191..e32fec67d 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -165,7 +165,23 @@ SurfaceImpl::SurfaceImpl()
SurfaceImpl::~SurfaceImpl()
{
- Release();
+ Clear();
+}
+
+void SurfaceImpl::Clear()
+{
+ if (painterOwned && painter) {
+ delete painter;
+ }
+
+ if (deviceOwned && device) {
+ delete device;
+ }
+
+ device = 0;
+ painter = 0;
+ deviceOwned = false;
+ painterOwned = false;
}
void SurfaceImpl::Init(WindowID wid)
@@ -197,18 +213,7 @@ void SurfaceImpl::InitPixMap(int width,
void SurfaceImpl::Release()
{
- if (painterOwned && painter) {
- delete painter;
- }
-
- if (deviceOwned && device) {
- delete device;
- }
-
- device = 0;
- painter = 0;
- deviceOwned = false;
- painterOwned = false;
+ Clear();
}
bool SurfaceImpl::Initialised()
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index 6749c4b0f..8a5edeacd 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -60,6 +60,8 @@ private:
const char *codecName;
QTextCodec *codec;
+ void Clear();
+
public:
SurfaceImpl();
virtual ~SurfaceImpl();
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 00b118c82..90433201e 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -513,6 +513,7 @@ class SurfaceGDI : public Surface {
void BrushColor(ColourDesired back);
void SetFont(Font &font_);
+ void Clear();
public:
SurfaceGDI();
@@ -578,10 +579,10 @@ SurfaceGDI::SurfaceGDI() :
}
SurfaceGDI::~SurfaceGDI() {
- Release();
+ Clear();
}
-void SurfaceGDI::Release() {
+void SurfaceGDI::Clear() {
if (penOld) {
::SelectObject(hdc, penOld);
::DeleteObject(pen);
@@ -613,6 +614,10 @@ void SurfaceGDI::Release() {
}
}
+void SurfaceGDI::Release() {
+ Clear();
+}
+
bool SurfaceGDI::Initialised() {
return hdc != 0;
}
@@ -1066,6 +1071,7 @@ class SurfaceD2D : public Surface {
float dpiScaleX;
float dpiScaleY;
+ void Clear();
void SetFont(Font &font_);
public:
@@ -1147,10 +1153,10 @@ SurfaceD2D::SurfaceD2D() :
}
SurfaceD2D::~SurfaceD2D() {
- Release();
+ Clear();
}
-void SurfaceD2D::Release() {
+void SurfaceD2D::Clear() {
if (pBrush) {
pBrush->Release();
pBrush = 0;
@@ -1167,6 +1173,10 @@ void SurfaceD2D::Release() {
}
}
+void SurfaceD2D::Release() {
+ Clear();
+}
+
void SurfaceD2D::SetScale() {
HDC hdcMeasure = ::CreateCompatibleDC(NULL);
logPixelsY = ::GetDeviceCaps(hdcMeasure, LOGPIXELSY);