Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get() MUIA_TextEditor_RedoAvailable from call hook #25

Closed
afalkenhahn opened this issue Jul 23, 2019 · 2 comments
Closed

Cannot get() MUIA_TextEditor_RedoAvailable from call hook #25

afalkenhahn opened this issue Jul 23, 2019 · 2 comments
Assignees
Labels

Comments

@afalkenhahn
Copy link

Trying to get() MUIA_TextEditor_RedoAvailable doesn't work from a call hook. Here's how to reproduce it:

  1. Enter a char
  2. Click the button to undo the operation
  3. Note the debug output: AppMsgFunc2 correctly receives 1 in the x argument because redo is now available. However, when querying MUIA_TextEditor_RedoAvailable using get() at the same time, y still receives 0 but it should be 1 now.

Here is the demo code:

#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>

#include <exec/exec.h>
#include <exec/types.h>

#include <intuition/intuition.h>

#include <libraries/mui.h>
#include <mui/TextEditor_mcc.h>

#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <proto/utility.h>

struct Library *MUIMasterBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;

#define REG(x) register __ ## x
#define ASM    __asm
#define SAVEDS __saveds

SAVEDS ASM LONG AppMsgFunc(REG(a2) APTR obj, REG(a1) int *x)
{
	int y = -1;
	
	get(obj, MUIA_TextEditor_UndoAvailable, &y);
	
	printf("Undo available: %d %d\n", *x, y);

	return(0);
}

SAVEDS ASM LONG AppMsgFunc2(REG(a2) APTR obj, REG(a1) int *x)
{
	int y = -1;
	
	get(obj, MUIA_TextEditor_RedoAvailable, &y);
	
	printf("Redo available: %d %d\n", *x, y);

	return(0);
}

int main(int argc, char *argv[])
{
	Object *win, *app, *bt, *editor;
	ULONG sigs = 0;
	ULONG id;
	int flag = 0;
	Object *subwin, *parent, *reg;
	static const struct Hook AppMsgHook = { { NULL,NULL },(VOID *)AppMsgFunc,NULL,NULL };	
	static const struct Hook AppMsgHook2 = { { NULL,NULL },(VOID *)AppMsgFunc2,NULL,NULL };	
	
	IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
	MUIMasterBase = OpenLibrary("muimaster.library", 0);

	app = ApplicationObject,
		MUIA_Application_Title, "Foo",
		MUIA_Application_Base, "xxxxx",

		SubWindow, win = WindowObject,
			MUIA_Window_Title, "Bar",

			WindowContents, VGroup,

				Child, VGroup,
				
					Child, editor = TextEditorObject,
						MUIA_CycleChain, 1,
					End,				
					Child, bt = SimpleButton("Click"),
				End,
			End,
		End,
	End;

	DoMethod(bt,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,1000);
	DoMethod(editor, MUIM_Notify, MUIA_TextEditor_UndoAvailable, MUIV_EveryTime, editor, 3, MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
	DoMethod(editor, MUIM_Notify, MUIA_TextEditor_RedoAvailable, MUIV_EveryTime, editor, 3, MUIM_CallHook,&AppMsgHook2,MUIV_TriggerValue);	
	DoMethod(win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

	set(win, MUIA_Window_Open, TRUE);

	while((id = DoMethod(app,MUIM_Application_NewInput,&sigs)) != MUIV_Application_ReturnID_Quit) {

		switch(id) {
		case 1000:
			DoMethod(editor, MUIM_TextEditor_ARexxCmd, "UNDO");				
			break;
		}
		
		if(sigs) {
			sigs = Wait(sigs | SIGBREAKF_CTRL_C);
			if (sigs & SIGBREAKF_CTRL_C) break;
		}
	}

	MUI_DisposeObject(app);

	if(MUIMasterBase) CloseLibrary(MUIMasterBase);
	if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);

	return 0;
}
 
@afalkenhahn
Copy link
Author

Btw, as you can see, MUIA_TextEditor_UndoAvailable behaves correctly. It's only MUIA_TextEditor_RedoAvailable that doesn't work correctly.

@tboeckel tboeckel self-assigned this Jul 28, 2019
@tboeckel tboeckel added the bug label Jul 28, 2019
@tboeckel
Copy link
Contributor

This version should fix the issue.
MCC_TextEditor-15.53.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants