2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-10-01 11:22:00 +00:00

Simplify XErrorHandlerRestorer API

This commit is contained in:
Ilya Fedin
2020-12-10 06:32:30 +04:00
committed by John Preston
parent 3297bdadb5
commit 05147016b0
3 changed files with 13 additions and 17 deletions

View File

@@ -17,8 +17,16 @@ namespace internal {
class XErrorHandlerRestorer::Private {
public:
Private() {}
int (*oldErrorHandler)(Display *, XErrorEvent *);
Private()
: _oldErrorHandler(XSetErrorHandler(nullptr)) {
}
~Private() {
XSetErrorHandler(_oldErrorHandler);
}
private:
int (*_oldErrorHandler)(Display *, XErrorEvent *);
};
XErrorHandlerRestorer::XErrorHandlerRestorer()
@@ -27,14 +35,6 @@ XErrorHandlerRestorer::XErrorHandlerRestorer()
XErrorHandlerRestorer::~XErrorHandlerRestorer() = default;
void XErrorHandlerRestorer::save() {
_private->oldErrorHandler = XSetErrorHandler(nullptr);
}
void XErrorHandlerRestorer::restore() {
XSetErrorHandler(_private->oldErrorHandler);
}
} // namespace internal
} // namespace Platform
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION