mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
fix possible crashes in case QCursor is used when qt_x11Data is null
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1d8cc1be87
commit
48f864a5f4
1 changed files with 16 additions and 7 deletions
|
@ -114,7 +114,7 @@ Qt::HANDLE QCursor::handle() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
Display *dpy = qt_x11Data->display;
|
||||
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||
if (!dpy) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -185,11 +185,14 @@ Qt::HANDLE QCursor::handle() const
|
|||
*/
|
||||
int QCursor::x11Screen()
|
||||
{
|
||||
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||
if (!dpy) {
|
||||
return -1;
|
||||
}
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint buttons;
|
||||
Display* dpy = qt_x11Data->display;
|
||||
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
||||
&win_x, &win_y, &buttons)) {
|
||||
|
@ -202,11 +205,14 @@ int QCursor::x11Screen()
|
|||
|
||||
QPoint QCursor::pos()
|
||||
{
|
||||
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||
if (!dpy) {
|
||||
return QPoint();
|
||||
}
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint buttons;
|
||||
Display* dpy = qt_x11Data->display;
|
||||
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
||||
&win_x, &win_y, &buttons)) {
|
||||
|
@ -218,18 +224,21 @@ QPoint QCursor::pos()
|
|||
|
||||
void QCursor::setPos(int x, int y)
|
||||
{
|
||||
Display *dpy = (qt_x11Data ? qt_x11Data->display : nullptr);
|
||||
if (!dpy) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPoint current;
|
||||
QPoint target(x, y);
|
||||
|
||||
// this is copied from pos(), since we need the screen number for the correct
|
||||
// root window in the XWarpPointer call
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint buttons;
|
||||
Display* dpy = qt_x11Data->display;
|
||||
int screen;
|
||||
for (screen = 0; screen < ScreenCount(dpy); ++screen) {
|
||||
int screen = 0;
|
||||
for (; screen < ScreenCount(dpy); ++screen) {
|
||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
|
||||
&win_x, &win_y, &buttons)) {
|
||||
current = QPoint(root_x, root_y);
|
||||
|
|
Loading…
Add table
Reference in a new issue