diff options
| author | Neil <nyamatongwe@gmail.com> | 2017-05-02 10:06:46 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2017-05-02 10:06:46 +1000 | 
| commit | ffeb34c29ffd27e1a1a67cb26ceec8fc1253a410 (patch) | |
| tree | 59d17870a0bea7b8a058100fdd98666227e7684e /src/EditView.cxx | |
| parent | 782ada0bab34bb56c4023c070e6eb355ca32cdf2 (diff) | |
| download | scintilla-mirror-ffeb34c29ffd27e1a1a67cb26ceec8fc1253a410.tar.gz | |
Use unique_ptr for drawing surfaces and don't check for allocation failure
as that throws an exception.
Also use unique_ptr for tab stop positions.
Diffstat (limited to 'src/EditView.cxx')
| -rw-r--r-- | src/EditView.cxx | 34 | 
1 files changed, 12 insertions, 22 deletions
| diff --git a/src/EditView.cxx b/src/EditView.cxx index 50555b0a1..d1ebc345a 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -175,7 +175,6 @@ void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRec  const XYPOSITION epsilon = 0.0001f;	// A small nudge to avoid floating point precision issues  EditView::EditView() { -	ldTabstops = NULL;  	tabWidthMinimumPixels = 2; // needed for calculating tab stops for fractional proportional fonts  	hideSelection = false;  	drawOverstrikeCaret = true; @@ -185,9 +184,6 @@ EditView::EditView() {  	additionalCaretsBlink = true;  	additionalCaretsVisible = true;  	imeCaretBlockOverride = false; -	pixmapLine = 0; -	pixmapIndentGuide = 0; -	pixmapIndentGuideHighlight = 0;  	llc.SetLevel(LineLayoutCache::llcCaret);  	posCache.SetSize(0x400);  	tabArrowHeight = 4; @@ -196,8 +192,6 @@ EditView::EditView() {  }  EditView::~EditView() { -	delete ldTabstops; -	ldTabstops = NULL;  }  bool EditView::SetTwoPhaseDraw(bool twoPhaseDraw) { @@ -219,8 +213,7 @@ bool EditView::LinesOverlap() const {  }  void EditView::ClearAllTabstops() { -	delete ldTabstops; -	ldTabstops = 0; +	ldTabstops.reset();  }  XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const { @@ -231,20 +224,20 @@ XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tab  }  bool EditView::ClearTabstops(Sci::Line line) { -	LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops); +	LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops.get());  	return lt && lt->ClearTabstops(line);  }  bool EditView::AddTabstop(Sci::Line line, int x) {  	if (!ldTabstops) { -		ldTabstops = new LineTabstops(); +		ldTabstops.reset(new LineTabstops());  	} -	LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops); +	LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops.get());  	return lt && lt->AddTabstop(line, x);  }  int EditView::GetNextTabstop(Sci::Line line, int x) const { -	const LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops); +	const LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops.get());  	if (lt) {  		return lt->GetNextTabstop(line, x);  	} else { @@ -268,12 +261,9 @@ void EditView::LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded) {  void EditView::DropGraphics(bool freeObjects) {  	if (freeObjects) { -		delete pixmapLine; -		pixmapLine = 0; -		delete pixmapIndentGuide; -		pixmapIndentGuide = 0; -		delete pixmapIndentGuideHighlight; -		pixmapIndentGuideHighlight = 0; +		pixmapLine.reset(); +		pixmapIndentGuide.reset(); +		pixmapIndentGuideHighlight.reset();  	} else {  		if (pixmapLine)  			pixmapLine->Release(); @@ -286,11 +276,11 @@ void EditView::DropGraphics(bool freeObjects) {  void EditView::AllocateGraphics(const ViewStyle &vsDraw) {  	if (!pixmapLine) -		pixmapLine = Surface::Allocate(vsDraw.technology); +		pixmapLine.reset(Surface::Allocate(vsDraw.technology));  	if (!pixmapIndentGuide) -		pixmapIndentGuide = Surface::Allocate(vsDraw.technology); +		pixmapIndentGuide.reset(Surface::Allocate(vsDraw.technology));  	if (!pixmapIndentGuideHighlight) -		pixmapIndentGuideHighlight = Surface::Allocate(vsDraw.technology); +		pixmapIndentGuideHighlight.reset(Surface::Allocate(vsDraw.technology));  }  static const char *ControlCharacterString(unsigned char ch) { @@ -1984,7 +1974,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan  		Surface *surface = surfaceWindow;  		if (bufferedDraw) { -			surface = pixmapLine; +			surface = pixmapLine.get();  			PLATFORM_ASSERT(pixmapLine->Initialised());  		}  		surface->SetUnicodeMode(SC_CP_UTF8 == model.pdoc->dbcsCodePage); | 
