Detect XRender initialization failures.

svn path=/trunk/KDE/kdebase/workspace/; revision=688970
This commit is contained in:
Luboš Luňák 2007-07-17 11:02:27 +00:00
parent 7b054df213
commit 263defdb87

View file

@ -36,6 +36,8 @@ License. See the file "COPYING" for the exact licensing terms.
#include "deleted.h" #include "deleted.h"
#include "effects.h" #include "effects.h"
#include <kxerrorhandler.h>
namespace KWin namespace KWin
{ {
@ -88,6 +90,7 @@ SceneXrender::SceneXrender( Workspace* ws )
kDebug( 1212 ) << "No xfixes v3+ extension available" << endl; kDebug( 1212 ) << "No xfixes v3+ extension available" << endl;
return; return;
} }
KXErrorHandler xerr;
// create XRender picture for the root window // create XRender picture for the root window
format = XRenderFindVisualFormat( display(), DefaultVisual( display(), DefaultScreen( display()))); format = XRenderFindVisualFormat( display(), DefaultVisual( display(), DefaultScreen( display())));
if( format == NULL ) if( format == NULL )
@ -104,13 +107,17 @@ SceneXrender::SceneXrender( Workspace* ws )
front = XRenderCreatePicture( display(), rootWindow(), format, CPSubwindowMode, &pa ); front = XRenderCreatePicture( display(), rootWindow(), format, CPSubwindowMode, &pa );
} }
createBuffer(); createBuffer();
init_ok = true; init_ok = !xerr.error( true );
} }
SceneXrender::~SceneXrender() SceneXrender::~SceneXrender()
{ {
if( !init_ok ) if( !init_ok )
{
// TODO this probably needs to clean up whatever has been created until the failure
wspace->destroyOverlay();
return; return;
}
XRenderFreePicture( display(), front ); XRenderFreePicture( display(), front );
XRenderFreePicture( display(), buffer ); XRenderFreePicture( display(), buffer );
wspace->destroyOverlay(); wspace->destroyOverlay();