[haiku-appserver] some help please

  • From: Adi Oanca <adioanca@xxxxxxxxxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Sat, 17 Sep 2005 21:00:51 +0300

Hi all,

Have a big big problem. app_server (under R5) gets into debugger and while I understand the reason, I can't I find out why this happens.

I have attached 3 files to this mail. The archive has 2 pictures of which I'll talk in a moment, then there's the test program and a stack crawl.

What happens is, as you can see in Screen1.tga, 'this' pointer is NULL. 'this' should've pointed to "RootLayer 1". This is VERY strange as, in the previous call, Layer::move_layer(), 'fParent' is valid!


I've spent several hours in solving this problem but had no success. If you please have some time to look into this, it's much appreciated. Thanks!



Now, how to reproduce:
- take main.cpp and link against our libbe.so (I use R5, so libopenbeos.so)
- run the server, run the app.
- move (quickly) the floating window around.
(if you are not able to reproduce this, I will submit the WIP that I have related to input stuff, and when this is enabled by a define in Layer.h, it crashes a lot more often)


NOTE: I'm using GeekGadgets' compiler. (never had a problem with it)


Thank you! Adi.
loading symbols
Assert failed: File: ../../kits/interface/RegionSupport.cpp, Line: 570, Thread: 
RootLayer 1.
Assert condition: foundCount > 0

_debugger:
_debugger:
+0007  ec06bb4b:   *            c3    retn
RootLayer 1:sc
   frame         retaddr
fd0ee804   ec068dd1  _debuggerAssert + 000001a1
fd0ee86c   ec8113d2  BRegion::Support::ROr(long, long, BRegion const &, BRegion 
const &, BRegion &, long *, long *) + 000003d6
fd0f08d4   ec8116e1  BRegion::Support::OrRegionComplex(BRegion const &, BRegion 
const &, BRegion &) + 000001a1
fd0f0914   ec811771  BRegion::Support::OrRegion1ToN(BRegion const &, BRegion 
const &, BRegion &) + 0000006d
fd0f092c   ec810721  BRegion::Support::OrRegion(BRegion const &, BRegion const 
&, BRegion &) + 0000010d
fd0f094c   ec80fae1  BRegion::Include(BRegion const *) + 00000031
fd0f0988   8005e199  Layer::StartRebuildRegions(BRegion const &, Layer *, 
unsigned long, BPoint &) + 0000019d
fd0f0a04   800613b8  Layer::move_layer(float, float) + 000000e4
fd0f0a84   80069acc  WinBorder::MoveBy(float, float) + 00000218
fd0f0b10   8006a68e  WinBorder::MouseMoved(PointerEvent const &) + 00000116
fd0f0b6c   800660be  RootLayer::MouseEventHandler(long, BPrivate::PortLink &) + 
00000b62
fd0f0cc0   80063135  RootLayer::WorkingThread(void *) + 00000255
fd0f0d3c   ec06c50d  thread_start + 00000039
RootLayer 1: 
#include <OS.h>
#include <Application.h>
#include <Window.h>
#include <View.h>
#include <Box.h>
#include <Rect.h>
#include <Button.h>
#include <Point.h>
#include <stdio.h>

const int32             offset = 0;
int32   no = 0;

class MyView : public BView
{
public:
                                                        MyView(BRect, const 
char*, uint32, uint32);
        virtual void                    MouseDown(BPoint point);
        virtual void                    KeyDown(const char* bytes, int32 
numBytes);
        virtual void                    KeyUp(const char* bytes, int32 
numBytes);
        virtual void                    MouseUp(BPoint point);
        virtual void                    MouseMoved(     BPoint where,
                                                                                
uint32 code,
                                                                                
const BMessage *a_message);
        virtual void    MessageReceived(BMessage *message);
        virtual void                    Draw(BRect rect);
};

class MyApp : public BApplication
{
public:
        MyApp(void);
};

class MyWin : public BWindow
{
public:
                                        MyWin(BRect rect, const char *name, 
window_look look, window_feel feel, uint32 flags, uint32 wks);
        virtual void    MessageReceived(BMessage *message);
        virtual void    WindowActivated(bool state);
        virtual void    WorkspaceActivated(int32 ws, bool state);
        virtual void    WorkspacesChanged(uint32 oldws, uint32 newws);
private:
        MyView                  *view;
};

MyWin *win,*win1
;//,*win2;

void MyView::Draw(BRect rect)
{
        StrokeLine(BPoint(20,20), BPoint(100,70));
}

MyView::MyView(BRect rect, const char* name, uint32 rm, uint32 flags)
        : BView(rect, name, rm, flags)
{
}

void MyView::MouseDown(BPoint point)
{
        SetMouseEventMask(B_POINTER_EVENTS);
        printf("%s Mouse Down: %f, %f\n", Name(), point.x, point.y);
}

void MyView::MouseUp(BPoint point)
{
        printf("%s Mouse UP: %f, %f\n", Name(), point.x, point.y);
}

void MyView::KeyDown(const char* bytes, int32 numBytes)
{
        printf("%s Key Down: %c\n", Name(), bytes[0]);
}

void MyView::KeyUp(const char* bytes, int32 numBytes)
{
        printf("%s Key UP: %c\n", Name(), bytes[0]);
}

void MyView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message)
{
/*
        printf("%s Mouse Move, location %f,%f  code: ", Name(), where.x, 
where.y);
        switch(code)
        {
                case B_ENTERED_VIEW:
                        printf("B_ENTERED_VIEW\n");
                        break;
                case B_INSIDE_VIEW:
                        printf("B_INSIDE_VIEW\n");
                        break;
                case B_EXITED_VIEW:
                        printf("B_EXITED_VIEW\n");
                        break;
                case B_OUTSIDE_VIEW:
                        printf("B_OUTSIDE_VIEW\n");
                        break;
        }
*/
}

void MyView::MessageReceived(BMessage *message)
{
        if (message->what == B_MOUSE_WHEEL_CHANGED)
                printf("Adi: Wheel\n");
//      else
//              message->PrintToStream();
}

MyWin::MyWin(BRect rect, const char *name, window_look look, window_feel feel, 
uint32 flags, uint32 wks)
        : BWindow(rect, name, look, feel, flags, wks)
{
        rgb_color       c;
        c.red           = 23;
        c.green         = 59;
        c.blue          = 124;
        c.alpha         = 255;
//      char            viewName[30];
        no++;
//      sprintf(viewName, "view %ld", no);
//      view = new MyView(Bounds().InsetByCopy(5,5),viewName, B_FOLLOW_NONE, 
B_WILL_DRAW | B_NAVIGABLE);
//      view = new MyView(BRect(50,20, 150,80),"bla", B_FOLLOW_NONE, 
B_WILL_DRAW | B_NAVIGABLE);
//      view->SetViewColor(c);
//      if (no!=3)
//      view->SetEventMask(B_POINTER_EVENTS);
//      view->Hide();
//      view->Show();
//      AddChild(view);
//      view->Hide();
//      view->Show();
//      AddChild(new BButton(BRect(50,20,150, 80), "B", "Hit!", new 
BMessage(222)));


        BRect b = Bounds();
        // controls occupy the left side of the window
        b.Set(b.left + 5.0, b.top + 5.0, ceilf((b.left + b.right) / 3.0) - 2.0, 
b.bottom - 5.0);

        BBox* controlGroup = new BBox(b, "controls box", B_FOLLOW_LEFT | 
B_FOLLOW_TOP_BOTTOM,
                                                                  B_WILL_DRAW, 
B_FANCY_BORDER);

        controlGroup->SetLabel("Controls");
        AddChild(controlGroup);

b.OffsetBy(70, 0);

        BView   *view = new BView(b, "controls box", B_FOLLOW_LEFT | 
B_FOLLOW_TOP_BOTTOM,
                                                                  B_WILL_DRAW);
        view->SetViewColor(24,130,90);
        AddChild(view);

b.OffsetBy(70, 0);

        view = new MyView(b,"bla", B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE);
        view->SetViewColor(c);
        AddChild(view);
}

void MyWin::WindowActivated(bool state)
{
        printf("%s::WindowActivated(%s)\n", Name(), state == true? "true": 
"false");
        printf("\tFront Status: win = %s, win1 = %s\n\tActive Status: win = %s, 
win1 = %s\n",
                win->IsFront()?"YES":"NO",
                win1->IsFront()?"YES":"NO",
                win->IsActive()?"YES":"NO",
                win1->IsActive()?"YES":"NO");
}

void MyWin::WorkspaceActivated(int32 ws, bool state)
{
        printf("%s::WorkspaceActivated(%ld, %s)...\n", Name(), ws, state == 
true? "true": "false");
}

void MyWin::WorkspacesChanged(uint32 oldws, uint32 newws)
{
        printf("%s::WorkspaceActivated(%ld, %ld)...\n", Name(), oldws, newws);
//      CurrentMessage()->PrintToStream();
}

void MyWin::MessageReceived(BMessage *message)
{
//      message->PrintToStream();
        BWindow::MessageReceived(message);
}

MyApp::MyApp(void)
 : BApplication("application/x-vnd.wgp-OBTestApp")
{
printf("Adi: MyApp\n");
//      MyWin *win=new 
        win=new
                MyWin(BRect(offset+100,100,offset+300,200),"NormalWindow1",
                B_DOCUMENT_WINDOW_LOOK,
//              B_NO_BORDER_WINDOW_LOOK,
                B_NORMAL_WINDOW_FEEL,
                0,
//              B_ASYNCHRONOUS_CONTROLS,
                0);
//                      B_FLOATING_APP_WINDOW_FEEL, 0);
//      snooze(2000000);
        win->MoveBy(50, 15);

/*
        snooze(200000);
        win->MoveBy(25, 25);
        snooze(200000);
        win->MoveBy(25, 25);
        snooze(200000);
        win->MoveBy(25, 25);
        snooze(200000);
        win->MoveBy(25, 25);

        snooze(200000);
        win->MoveBy(-25, 25);
        snooze(200000);
        win->MoveBy(25, -25);
        snooze(200000);
        win->MoveBy(25, -25);
        snooze(200000);
        win->MoveBy(-25, 25);
*/

//      MyWin *win1=new 
        win1=new
                MyWin(BRect(offset+200,200,offset+400,350),"FlaotingAppWindow",
                B_DOCUMENT_WINDOW_LOOK,
//              B_NO_BORDER_WINDOW_LOOK,
//              B_NORMAL_WINDOW_FEEL, 0, 0);
                B_FLOATING_APP_WINDOW_FEEL, 0, 0);
        win->Show();
        win1->Show();

//      MyWin *win2=new 
//              
MyWin(BRect(offset+400,100,offset+600,200),"ModalAppWindow",B_DOCUMENT_WINDOW_LOOK,
//              B_NORMAL_WINDOW_FEEL, 0, 0);
//              B_FLOATING_APP_WINDOW_FEEL, 0);
//              B_MODAL_APP_WINDOW_FEEL, 0, 0);
//      win2->Show();


//      MyWin *win2=new 
//              MyWin(BRect(offset+400,100,offset+600,200),"floatALL",
//              B_DOCUMENT_WINDOW_LOOK,
//              B_NORMAL_WINDOW_FEEL, 0, 0);
//                      B_FLOATING_APP_WINDOW_FEEL, 0);
//                      B_FLOATING_SUBSET_WINDOW_FEEL, 0);
//                      B_MODAL_SUBSET_WINDOW_FEEL, 0);
//                      B_MODAL_APP_WINDOW_FEEL, 0);
//                      B_FLOATING_ALL_WINDOW_FEEL, 0, 0);
//                      B_MODAL_ALL_WINDOW_FEEL, 0,0);
//      win2->Show();

//      win2->AddToSubset(win1);

//      MyWin *win3=new 
//              
MyWin(BRect(offset+400,300,offset+600,400),"ZTestWindow4",B_DOCUMENT_WINDOW_LOOK,
//              B_NORMAL_WINDOW_FEEL,0);
//                      B_FLOATING_APP_WINDOW_FEEL, 0);
//                      B_FLOATING_SUBSET_WINDOW_FEEL, 0);
//                      B_MODAL_SUBSET_WINDOW_FEEL, 0, 0);
//                      B_MODAL_APP_WINDOW_FEEL, 0, 0x8UL);
//      snooze(2000000);
//      win3->Show();

//      win3->AddToSubset(win1);

//      snooze(2000000);
//      win->Hide();
//
//      snooze(2000000);
//      win->Show();

//      win->Lock();
//      win->Quit();
//      delete win;

//      win3->Show();
//      win1->SetWorkspaces(0x4UL);



//      win->SetWorkspaces(0x3UL);



//      snooze(2000000);
//      win2->Hide();
//      snooze(2000000);
//      win2->Show();

//      snooze(2000000);
//      win1->Hide();
//      snooze(2000000);
//      win1->Show();


}

int main(void)
{
        MyApp app;
        app.Run();
}

Other related posts: