aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/PlatGTK.cxx16
-rw-r--r--src/Editor.cxx7
2 files changed, 23 insertions, 0 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index c1e5566e5..d4572a912 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -527,6 +527,22 @@ void SurfaceImpl::Release() {
}
bool SurfaceImpl::Initialised() {
+ if (inited && context) {
+ if (cairo_status(context) == CAIRO_STATUS_SUCCESS) {
+ // Even when status is success, the target surface may have been
+ // finished whch may cause an assertion to fail crashing the application.
+ // The cairo_surface_has_show_text_glyphs call checks the finished flag
+ // and when set, sets the status to CAIRO_STATUS_SURFACE_FINISHED
+ // which leads to warning messages instead of crashes.
+ // Performing the check in this method as it is called rarely and has no
+ // other side effects.
+ cairo_surface_t *psurfContext = cairo_get_target(context);
+ if (psurfContext) {
+ cairo_surface_has_show_text_glyphs(psurfContext);
+ }
+ }
+ return cairo_status(context) == CAIRO_STATUS_SUCCESS;
+ }
return inited;
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 63d45158b..18eafa271 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1830,6 +1830,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
RefreshStyleData();
RefreshPixMaps(surfWindow);
+ // On GTK+ with Ubuntu overlay scroll bars, the surface may have been finished
+ // at this point. The Initialised call checks for this case and sets the status
+ // to be bad which avoids crashes in following calls.
+ if (!surfWindow->Initialised()) {
+ return;
+ }
+
PRectangle rcMargin = GetClientRectangle();
Point ptOrigin = GetVisibleOriginInMain();
rcMargin.Move(0, -ptOrigin.y);