mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-25 22:03:45 -06:00
CtrlCore: X11 Fixed issue with memory leaks causing segmentation fault without displaying the warning
git-svn-id: svn://ultimatepp.org/upp/trunk@4133 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e78884acec
commit
88340cd36a
4 changed files with 123 additions and 118 deletions
|
|
@ -19,6 +19,7 @@ void InstallPanicMessageBox(void (*mb)(const char *title, const char *text))
|
|||
|
||||
void PanicMessageBox(const char *title, const char *text)
|
||||
{
|
||||
PanicMode = true;
|
||||
if(sPanicMessageBox)
|
||||
(*sPanicMessageBox)(title, text);
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -153,12 +153,15 @@ void Ctrl::UntrapX11Errors(bool b)
|
|||
X11ErrorTrap = b;
|
||||
}
|
||||
|
||||
static void sPanicMessageBox(const char *title, const char *text)
|
||||
void sPanicMessageBox(const char *title, const char *text)
|
||||
{
|
||||
GuiLock __;
|
||||
write(2, text, strlen(text));
|
||||
write(2, "\n", 1);
|
||||
Ctrl::ReleaseCtrlCapture();
|
||||
if(Ctrl::grabWindow) {
|
||||
LLOG("RELEASE GRAB");
|
||||
XUngrabPointer(Xdisplay, CurrentTime);
|
||||
XFlush(Xdisplay);
|
||||
}
|
||||
XDisplay *display = XOpenDisplay(NULL);
|
||||
if(!display)
|
||||
return;
|
||||
|
|
@ -233,11 +236,11 @@ static void sPanicMessageBox(const char *title, const char *text)
|
|||
|
||||
int X11ErrorHandler(XDisplay *, XErrorEvent *error)
|
||||
{
|
||||
if(X11ErrorTrap || IsPanicMode()) return 0;
|
||||
|
||||
if(GetIniKey(INI_PREFIX "X11_ERRORS") != "1")
|
||||
return 0;
|
||||
|
||||
if(X11ErrorTrap || IsPanicMode()) return 0;
|
||||
|
||||
static const char *request[] = {
|
||||
"",
|
||||
"X_CreateWindow",
|
||||
|
|
|
|||
|
|
@ -1,112 +1,113 @@
|
|||
//$ class Ctrl {
|
||||
bool ignoretakefocus:1;
|
||||
protected:
|
||||
struct XWindow {
|
||||
Ptr<Ctrl> ctrl;
|
||||
bool exposed;
|
||||
Vector<Rect> invalid;
|
||||
Ptr<Ctrl> owner;
|
||||
Ptr<Ctrl> last_active;
|
||||
XIC xic;
|
||||
};
|
||||
|
||||
private:
|
||||
static ArrayMap<Window, XWindow>& Xwindow();
|
||||
static int WndCaretTime;
|
||||
static bool WndCaretVisible;
|
||||
static int Xbuttons;
|
||||
static int Xbuttontime;
|
||||
static Point Xbuttonpos;
|
||||
static Window grabWindow, focusWindow;
|
||||
static Point mousePos;
|
||||
static int PopupGrab;
|
||||
static Ptr<Ctrl> popupWnd;
|
||||
static Index<String> sel_formats;
|
||||
static Ptr<Ctrl> sel_ctrl;
|
||||
static void ProcessEvent(XEvent *event);
|
||||
static void TimerAndPaint();
|
||||
static void ProcessEvent(XEvent& event);
|
||||
void Invalidate(XWindow& xw, const Rect& r);
|
||||
static void AnimateCaret();
|
||||
void DoPaint(const Vector<Rect>& invalid);
|
||||
void SetLastActive(XWindow *w, Ctrl *la);
|
||||
XWindow *GetXWindow();
|
||||
static void SyncMousePos();
|
||||
static void ReleaseGrab();
|
||||
static Vector<Callback> hotkey;
|
||||
static Vector<dword> modhot;
|
||||
static Vector<dword> keyhot;
|
||||
|
||||
void StartPopupGrab();
|
||||
static void EndPopupGrab();
|
||||
static void SyncIMPosition();
|
||||
|
||||
friend bool GetMouseRight();
|
||||
friend bool GetMouseLeft();
|
||||
friend bool GetMouseMiddle();
|
||||
friend Point GetMousePos();
|
||||
|
||||
protected:
|
||||
void Create(Ctrl *owner, bool redirect, bool savebits);
|
||||
void Create0(Ctrl *owner, bool redirect, bool savebits);
|
||||
void SyncExpose();
|
||||
void TakeFocus();
|
||||
static Window GetXServerFocusWindow();
|
||||
void AddGlobalRepaint();
|
||||
static void KillFocus(Window w);
|
||||
static void FocusSync();
|
||||
|
||||
void DropEvent(XWindow& w, XEvent *event);
|
||||
static void DropStatusEvent(XEvent *event);
|
||||
static Index<String> drop_formats;
|
||||
static String Unicode(const WString& w);
|
||||
static WString Unicode(const String& s);
|
||||
static bool ClipHas(int type, const char *fmt);
|
||||
static String ClipGet(int type, const char *fmt);
|
||||
|
||||
XWindow *AddXWindow(Window &w);
|
||||
void RemoveXWindow(Window &w);
|
||||
XWindow *XWindowFromWindow(Window &w);
|
||||
|
||||
public:
|
||||
struct Xclipboard {
|
||||
Window win;
|
||||
|
||||
VectorMap<int, ClipData> data;
|
||||
|
||||
String Read(int fmt, int selection, int property);
|
||||
void Write(int fmt, const ClipData& data);
|
||||
bool IsAvailable(int fmt, const char *type);
|
||||
|
||||
void Clear() { data.Clear(); }
|
||||
void Request(XSelectionRequestEvent *se);
|
||||
|
||||
Xclipboard();
|
||||
~Xclipboard();
|
||||
};
|
||||
|
||||
static Xclipboard& xclipboard();
|
||||
|
||||
static int Xeventtime;
|
||||
|
||||
static XIM xim;
|
||||
|
||||
void DnD(Window src, bool paste);
|
||||
|
||||
virtual void EventProc(XWindow& w, XEvent *event);
|
||||
virtual bool HookProc(XEvent *event);
|
||||
Window GetWindow() const { return top ? top->window : None; }
|
||||
static Ctrl *CtrlFromWindow(Window w);
|
||||
static bool TrapX11Errors();
|
||||
static void UntrapX11Errors(bool b);
|
||||
|
||||
Window GetParentWindow(void) const;
|
||||
Ctrl *GetParentWindowCtrl(void) const;
|
||||
Rect GetRectInParentWindow(void) const;
|
||||
|
||||
static void SyncNativeWindows(void);
|
||||
public:
|
||||
static void InitX11(const char *display);
|
||||
static void ExitX11();
|
||||
static void GuiFlush() { XFlush(Xdisplay); }
|
||||
//$ };
|
||||
//$ class Ctrl {
|
||||
bool ignoretakefocus:1;
|
||||
protected:
|
||||
struct XWindow {
|
||||
Ptr<Ctrl> ctrl;
|
||||
bool exposed;
|
||||
Vector<Rect> invalid;
|
||||
Ptr<Ctrl> owner;
|
||||
Ptr<Ctrl> last_active;
|
||||
XIC xic;
|
||||
};
|
||||
|
||||
private:
|
||||
static ArrayMap<Window, XWindow>& Xwindow();
|
||||
static int WndCaretTime;
|
||||
static bool WndCaretVisible;
|
||||
static int Xbuttons;
|
||||
static int Xbuttontime;
|
||||
static Point Xbuttonpos;
|
||||
static Window grabWindow, focusWindow;
|
||||
static Point mousePos;
|
||||
static int PopupGrab;
|
||||
static Ptr<Ctrl> popupWnd;
|
||||
static Index<String> sel_formats;
|
||||
static Ptr<Ctrl> sel_ctrl;
|
||||
static void ProcessEvent(XEvent *event);
|
||||
static void TimerAndPaint();
|
||||
static void ProcessEvent(XEvent& event);
|
||||
void Invalidate(XWindow& xw, const Rect& r);
|
||||
static void AnimateCaret();
|
||||
void DoPaint(const Vector<Rect>& invalid);
|
||||
void SetLastActive(XWindow *w, Ctrl *la);
|
||||
XWindow *GetXWindow();
|
||||
static void SyncMousePos();
|
||||
static void ReleaseGrab();
|
||||
static Vector<Callback> hotkey;
|
||||
static Vector<dword> modhot;
|
||||
static Vector<dword> keyhot;
|
||||
|
||||
void StartPopupGrab();
|
||||
static void EndPopupGrab();
|
||||
static void SyncIMPosition();
|
||||
|
||||
friend bool GetMouseRight();
|
||||
friend bool GetMouseLeft();
|
||||
friend bool GetMouseMiddle();
|
||||
friend Point GetMousePos();
|
||||
friend void sPanicMessageBox(const char *title, const char *text);
|
||||
|
||||
protected:
|
||||
void Create(Ctrl *owner, bool redirect, bool savebits);
|
||||
void Create0(Ctrl *owner, bool redirect, bool savebits);
|
||||
void SyncExpose();
|
||||
void TakeFocus();
|
||||
static Window GetXServerFocusWindow();
|
||||
void AddGlobalRepaint();
|
||||
static void KillFocus(Window w);
|
||||
static void FocusSync();
|
||||
|
||||
void DropEvent(XWindow& w, XEvent *event);
|
||||
static void DropStatusEvent(XEvent *event);
|
||||
static Index<String> drop_formats;
|
||||
static String Unicode(const WString& w);
|
||||
static WString Unicode(const String& s);
|
||||
static bool ClipHas(int type, const char *fmt);
|
||||
static String ClipGet(int type, const char *fmt);
|
||||
|
||||
XWindow *AddXWindow(Window &w);
|
||||
void RemoveXWindow(Window &w);
|
||||
XWindow *XWindowFromWindow(Window &w);
|
||||
|
||||
public:
|
||||
struct Xclipboard {
|
||||
Window win;
|
||||
|
||||
VectorMap<int, ClipData> data;
|
||||
|
||||
String Read(int fmt, int selection, int property);
|
||||
void Write(int fmt, const ClipData& data);
|
||||
bool IsAvailable(int fmt, const char *type);
|
||||
|
||||
void Clear() { data.Clear(); }
|
||||
void Request(XSelectionRequestEvent *se);
|
||||
|
||||
Xclipboard();
|
||||
~Xclipboard();
|
||||
};
|
||||
|
||||
static Xclipboard& xclipboard();
|
||||
|
||||
static int Xeventtime;
|
||||
|
||||
static XIM xim;
|
||||
|
||||
void DnD(Window src, bool paste);
|
||||
|
||||
virtual void EventProc(XWindow& w, XEvent *event);
|
||||
virtual bool HookProc(XEvent *event);
|
||||
Window GetWindow() const { return top ? top->window : None; }
|
||||
static Ctrl *CtrlFromWindow(Window w);
|
||||
static bool TrapX11Errors();
|
||||
static void UntrapX11Errors(bool b);
|
||||
|
||||
Window GetParentWindow(void) const;
|
||||
Ctrl *GetParentWindowCtrl(void) const;
|
||||
Rect GetRectInParentWindow(void) const;
|
||||
|
||||
static void SyncNativeWindows(void);
|
||||
public:
|
||||
static void InitX11(const char *display);
|
||||
static void ExitX11();
|
||||
static void GuiFlush() { XFlush(Xdisplay); }
|
||||
//$ };
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "Draw/init"
|
||||
#include "plugin\bmp/init"
|
||||
#include "RichText/init"
|
||||
#define BLITZ_INDEX__ F58C23D3C57D9E639358E3B0D8F9A293E
|
||||
#define BLITZ_INDEX__ F4A0E2450AF6499214C0E1EC13352603A
|
||||
#include "CtrlCore.icpp"
|
||||
#undef BLITZ_INDEX__
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue