[TextEditor_mcc] An example for the crash with hidden object

  • From: Mathias PARNAUDEAU <mathias.p@xxxxxxxxxx>
  • To: texteditor_mcc@xxxxxxxxxxxxx
  • Date: Thu, 21 Jul 2005 19:54:35 +0200

Hi,

Sorry to be late, I was off for more than a week ... But I just wrote a
small example to localize the problem. If the texteditor object is in a
hidden page of a register group, the program freezes if you insert text. It
works if you clear the text for example.

I use MorphOS and compiled it with :
gcc -noixemul -o testtexteditor testtexteditor.c

I don't know if this special case will frequently happen but that seems to
be a bug :-/

-- 
Mathias PARNAUDEAU
/*
 * This tools show how the program freezes when text is inserted into a 
texteditor object.
 */

#include <stdio.h>
#include <string.h>

#include <libraries/mui.h>
#include <proto/muimaster.h>
#include <proto/exec.h>
#include <clib/alib_protos.h>

#include <mui/TextEditor_mcc.h>

#define MAKE_ID(a,b,c,d)  ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | 
(ULONG) (d))

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

#define MUIA_Application_UsedClasses    0x8042e9a7      /* V20 STRPTR * i..     
*/

static char *ClassList[] =
{
        "TextEditor.mcc", NULL
};

static Object *app = NULL;
static Object *window = NULL;

static char *page_titles[] = { "First page", "Second page", NULL };


Object * OpenMainWindow(void)
{
        Object *texteditor, *text, *insert_button, *clear_button, *pages;

        app = (Object *)ApplicationObject,
                MUIA_Application_Author, "APPAUTHOR",
                MUIA_Application_Base, "APPBASE",
                MUIA_Application_Title, "APPTITLE",
                MUIA_Application_Version, "APPVERSION",
                MUIA_Application_Copyright, "APPCOPYRIGHT",
                MUIA_Application_Description, "APPDESCRIPTION",
                MUIA_Application_HelpFile, NULL,
                MUIA_Application_UsedClasses, ClassList,

                SubWindow, window = WindowObject,
                        MUIA_Window_Title, "TextEditor test with pages",
                        MUIA_Window_ID, MAKE_ID('W', 'I', 'N', '1'),
                        WindowContents, VGroup,

                                Child, HGroup,
                                        Child, insert_button = 
KeyButton("Insert into texteditor", 'i'),
                                        Child, clear_button = KeyButton("Clear 
texteditor object", 'c'),
                                End,

                                Child, pages = RegisterGroup(page_titles),
                                        MUIA_Register_Frame, TRUE,
                                        
                                        Child, texteditor = TextEditorObject,
                                        End,
                                        Child, VGroup,
                                                Child, text = TextObject,
                                                        MUIA_Frame, 
MUIV_Frame_Text,
                                                        MUIA_Text_Contents, 
"blablabla",
                                                End,
                                        End,

                                End,
                        End,
                End,
        End;

        if (app){
        
                DoMethod(window,
                        MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
                        app, 2,
                        MUIM_Application_ReturnID, 
MUIV_Application_ReturnID_Quit);

                DoMethod(insert_button, MUIM_Notify, MUIA_Pressed, FALSE,
                        texteditor, 2, MUIM_TextEditor_InsertText, "This is the 
inserted text !");

                DoMethod(clear_button, MUIM_Notify, MUIA_Pressed, FALSE,
                        texteditor, 1, MUIM_TextEditor_ClearText);

                SetAttrs(window, MUIA_Window_Open, TRUE, TAG_END);
        }

        return app;
}

int Initialize(void)
{
        int res = 1;

        IntuitionBase = (struct IntuitionBase 
*)OpenLibrary("intuition.library", 39L);
        MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN);

        if (IntuitionBase == NULL){
                printf("Impossible d'ouvrir 'intuition.library' V39\n");
                res = 0;
        }
        if (MUIMasterBase == NULL){
                printf("Impossible d'ouvrir '%s' V%d\n", MUIMASTER_NAME, 
MUIMASTER_VMIN);
                res = 0;
        }

        return res;
}


void DeInitialize(void)
{
        CloseLibrary(MUIMasterBase);
        CloseLibrary((struct Library *)IntuitionBase);
}


int main(int argc, char **argv)
{
        int res = 0;

        if (Initialize()){
                app = OpenMainWindow();
                if (app){
                        ULONG sigs = 0;

                        while (DoMethod(app,MUIM_Application_NewInput,&sigs) != 
MUIV_Application_ReturnID_Quit)
                        {
                                if (sigs)
                                {
                                        sigs = Wait(sigs | SIGBREAKF_CTRL_C);
                                        if (sigs & SIGBREAKF_CTRL_C) break;
                                }
                        }

                        set(window, MUIA_Window_Open, FALSE);
                        MUI_DisposeObject(app);
                }else{
                        res = 2;
                }
        }else{
                res = 1;
        }

        DeInitialize();

        return res;
}

Other related posts: