remove calltip_ignore_arg.patch
[nedit-bw.git] / enhanced-hooks-fix.patch
blob2b0c30b59c7dccc76f925492a33d8f4ad18637f8
1 ---
3 source/macro.c | 19 ++++++++++++++++---
4 source/macro.h | 2 +-
5 source/nedit.h | 1 +
6 source/window.c | 6 ++++++
7 4 files changed, 24 insertions(+), 4 deletions(-)
9 diff --quilt old/source/macro.c new/source/macro.c
10 --- old/source/macro.c
11 +++ new/source/macro.c
12 @@ -1279,12 +1279,14 @@ static void finishMacroCmdExecution(Wind
13 void SafeGC(void)
15 WindowInfo *win;
17 for (win=WindowList; win!=NULL; win=win->next)
18 - if (win->macroCmdData != NULL || InSmartIndentMacros(win))
19 - return;
20 + if (win->macroCmdData != NULL
21 + || InSmartIndentMacros(win)
22 + || win->inMacroHook)
23 + return;
24 GarbageCollectStrings();
28 ** Executes macro string "macro" using the lastFocus pane in "window".
29 @@ -6045,11 +6047,11 @@ static int readStringArg(DataValue dv, c
30 *errMsg = "%s called with unknown object";
31 return False;
34 /* rough hack */
35 -void MacroApplyHook(const WindowInfo* document, const char* hook, int argc,
36 +void MacroApplyHook(WindowInfo* document, const char* hook, int argc,
37 DataValue* argv, DataValue* resultDV)
39 Symbol* hookSymbol;
41 hookSymbol = LookupSymbol(hook);
42 @@ -6059,10 +6061,12 @@ void MacroApplyHook(const WindowInfo* do
43 DataValue dummyResultDV; /* Passed to ExecuteMacro() if no result requested */
44 int status;
45 char* errMsg;
46 // char statusT[1024];
48 + document->inMacroHook++;
50 /* Let 'er rip */
51 status = ExecuteMacro((WindowInfo*) document, hookProg, argc, argv,
52 (NULL == resultDV) ? &dummyResultDV : resultDV, &restartData,
53 &errMsg);
54 // switch (status)
55 @@ -6077,10 +6081,19 @@ void MacroApplyHook(const WindowInfo* do
56 while (MACRO_TIME_LIMIT == status) {
57 status = ContinueMacro(restartData,
58 (NULL == resultDV) ? &dummyResultDV : resultDV, &errMsg);
61 + document->inMacroHook--;
62 + /* call the GC only if the caller of this function is not interested
63 + ** in any result, else it may happen, that strings and arrays are swept
64 + ** away by the GC
65 + */
66 + if (NULL == resultDV) {
67 + SafeGC();
68 + }
70 if (MACRO_PREEMPT == status || MACRO_ERROR == status) {
71 fprintf(stderr, "nedit: \"%s\" error: %s\n", hook, (MACRO_ERROR == status) ? errMsg : "No dialogs");
72 } else {
73 /* Macro is done here */
75 diff --quilt old/source/nedit.h new/source/nedit.h
76 --- old/source/nedit.h
77 +++ new/source/nedit.h
78 @@ -567,10 +567,11 @@ typedef struct _WindowInfo {
79 UserMenuCache *userMenuCache; /* cache user menus: */
80 UserBGMenuCache userBGMenuCache; /* shell & macro menu are shared over all
81 "tabbed" documents, while each document
82 has its own background menu. */
83 Boolean transient;
84 + int inMacroHook; /* to protect GC in MacroApplyHook() */
85 } WindowInfo;
87 extern WindowInfo *WindowList;
88 extern Display *TheDisplay;
89 extern Widget TheAppShell;
90 diff --quilt old/source/window.c new/source/window.c
91 --- old/source/window.c
92 +++ new/source/window.c
93 @@ -265,10 +265,11 @@ WindowInfo *CreateWindow(const char *nam
94 window->autoSaveOpCount = 0;
95 window->undoOpCount = 0;
96 window->undoMemUsed = 0;
97 CLEAR_ALL_LOCKS(window->lockReasons);
98 window->transient = False;
99 + window->inMacroHook = 0;
100 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
101 window->autoSave = GetPrefAutoSave();
102 window->saveOldVersion = GetPrefSaveOldVersion();
103 window->wrapMode = GetPrefWrap(PLAIN_LANGUAGE_MODE);
104 window->showWrapMargin = GetPrefShowWrapMargin();
105 @@ -1011,10 +1012,14 @@ void CloseWindow(WindowInfo *window)
106 RefreshTabState(window);
107 updateLineNumDisp(window);
108 return;
111 + if (window->inMacroHook) {
112 + fprintf(stderr, "NEdit: warning closing window while in MacroHook\n");
115 /* Free syntax highlighting patterns, if any. w/o redisplaying */
116 FreeHighlightingData(window);
118 /* remove the buffer modification callbacks so the buffer will be
119 deallocated when the last text widget is destroyed */
120 @@ -3371,10 +3376,11 @@ WindowInfo* CreateDocument(WindowInfo* s
121 window->autoSaveOpCount = 0;
122 window->undoOpCount = 0;
123 window->undoMemUsed = 0;
124 CLEAR_ALL_LOCKS(window->lockReasons);
125 window->transient = False;
126 + window->inMacroHook = 0;
127 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
128 window->autoSave = GetPrefAutoSave();
129 window->saveOldVersion = GetPrefSaveOldVersion();
130 window->wrapMode = GetPrefWrap(PLAIN_LANGUAGE_MODE);
131 window->showWrapMargin = GetPrefShowWrapMargin();
132 diff --quilt old/source/macro.h new/source/macro.h
133 --- old/source/macro.h
134 +++ new/source/macro.h
135 @@ -72,9 +72,9 @@ int CheckMacroString(Widget dialogParent
136 char **errPos);
137 char *GetReplayMacro(void);
138 void ReadMacroInitFile(WindowInfo *window);
139 void ReturnShellCommandOutput(WindowInfo *window, const char *outText, int status);
140 struct DataValueTag;
141 -void MacroApplyHook(const WindowInfo* document, const char *hook, int argc,
142 +void MacroApplyHook(WindowInfo* document, const char *hook, int argc,
143 struct DataValueTag* argv, struct DataValueTag* resultDV);
145 #endif /* NEDIT_MACRO_H_INCLUDED */