• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KXErrorHandler Class Reference

This class simplifies handling of X errors. More...

#include <kxerrorhandler.h>

List of all members.


Public Member Functions

bool error (bool sync) const
XErrorEvent errorEvent () const
 KXErrorHandler (bool(*handler)(int request, int error_code, unsigned long resource_id), Display *dpy=QX11Info::display()) KDE_DEPRECATED
 KXErrorHandler (int(*handler)(Display *, XErrorEvent *), Display *dpy=QX11Info::display())
 KXErrorHandler (Display *dpy=QX11Info::display())
 ~KXErrorHandler ()

Static Public Member Functions

static QByteArray errorMessage (const XErrorEvent &e, Display *dpy=QX11Info::display())

Detailed Description

This class simplifies handling of X errors.

It shouldn't be necessary to use with Qt classes, as the toolkit should handle X errors itself, so this class will be mainly used with direct Xlib usage, and some lowlevel classes like NETWinInfo.

The usual usage is to create a KXErrorHandler instance right before starting operations that might cause X errors, and checking if there was an error by calling error() after the operations are finished. The handlers may be nested, but must be destroyed in reverse order they were created.

There's no need to do X sync before creating an instance, every instance will handle only errors for request issued after the instance was created. Errors for older requests will be passed to previous error handler. When checking for error by calling error() at the end, it is necessary to sync with X, to catch all errors that were caused by requests issued before the call to error(). This can be done by passing true to error() to cause explicit XSync(), however, if the last X request needed a roundtrip (e.g. XGetWindowAttributes(), XGetGeometry(), etc.), it is not required to do an explicit sync.

Author:
Lubos Lunak <l.lunak@kde.org> Handler for X errors

Definition at line 62 of file kxerrorhandler.h.


Constructor & Destructor Documentation

KXErrorHandler::KXErrorHandler ( Display *  dpy = QX11Info::display()  )  [explicit]

Creates error handler that will set error flag after encountering any X error.

Definition at line 52 of file kxerrorhandler.cpp.

KXErrorHandler::KXErrorHandler ( int(*)(Display *, XErrorEvent *)  handler,
Display *  dpy = QX11Info::display() 
) [explicit]

This constructor takes pointer to a function whose prototype matches the one that's used with the XSetErrorHandler() Xlib function.

NOTE: For the error flag to be set, the function must return a non-zero value.

Definition at line 70 of file kxerrorhandler.cpp.

KXErrorHandler::KXErrorHandler ( bool(*)(int request, int error_code, unsigned long resource_id)  handler,
Display *  dpy = QX11Info::display() 
) [explicit]

This constructor takes pointer to a function that will get request number, error code number and resource id of the failed request, as provided by XErrorEvent.

If the function returns true, the error flag will be set.

Deprecated:
Use the variant with XErrorEvent.

Definition at line 61 of file kxerrorhandler.cpp.

KXErrorHandler::~KXErrorHandler (  ) 

Definition at line 79 of file kxerrorhandler.cpp.


Member Function Documentation

bool KXErrorHandler::error ( bool  sync  )  const

This function returns true if the error flag is set (i.e.

no custom handler function was used and there was any error, or the custom handler indicated an error by its return value).

Parameters:
sync if true, an explicit XSync() will be done. Not necessary when the last X request required a roundtrip.

Definition at line 97 of file kxerrorhandler.cpp.

XErrorEvent KXErrorHandler::errorEvent (  )  const

This function returns the error event for the first X error that occurred.

The return value is useful only if error() returned true.

Since:
4.0.1

Definition at line 104 of file kxerrorhandler.cpp.

QByteArray KXErrorHandler::errorMessage ( const XErrorEvent &  e,
Display *  dpy = QX11Info::display() 
) [static]

Returns error message for the given error.

The error message is not translated, as it is meant for debugging.

Since:
4.0.1

Definition at line 148 of file kxerrorhandler.cpp.


The documentation for this class was generated from the following files:
  • kxerrorhandler.h
  • kxerrorhandler.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal