vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / menu_crash / MenuCrash.cpp
blob67e1c5f7250060d269be32db623aacc94ee396d3
1 /*
2 * Copyright 2007, Haiku Inc.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
10 #include <stdio.h>
12 #include <Application.h>
13 #include <Menu.h>
14 #include <MenuBar.h>
15 #include <MenuItem.h>
16 #include <View.h>
17 #include <Window.h>
20 class MenuItem : public BMenuItem {
21 public:
22 MenuItem(const char* name);
23 virtual ~MenuItem();
25 virtual void DrawContent();
29 MenuItem::MenuItem(const char* name)
30 : BMenuItem(name, NULL)
35 MenuItem::~MenuItem()
40 void
41 MenuItem::DrawContent()
43 *(uint32*)0 = 0;
47 // #pragma mark -
50 class Window : public BWindow {
51 public:
52 Window();
53 virtual ~Window();
55 virtual bool QuitRequested();
59 Window::Window()
60 : BWindow(BRect(100, 100, 400, 400), "MenuCrash-Test",
61 B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
63 BMenuBar* menuBar = new BMenuBar(Bounds(), "menu");
64 AddChild(menuBar);
66 // add menu
68 BMenu* menu = new BMenu("File");
69 BMenu* crashMenu = new BMenu("Crash");
70 crashMenu->AddItem(new MenuItem("Crash"));
71 menu->AddItem(crashMenu);
73 menu->AddSeparatorItem();
75 menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
76 'Q', B_COMMAND_KEY));
77 menu->SetTargetForItems(this);
78 menuBar->AddItem(menu);
81 Window::~Window()
86 bool
87 Window::QuitRequested()
89 be_app->PostMessage(B_QUIT_REQUESTED);
90 return true;
94 // #pragma mark -
97 class Application : public BApplication {
98 public:
99 Application();
101 virtual void ReadyToRun(void);
105 Application::Application()
106 : BApplication("application/x-vnd.haiku-menu_crash")
111 void
112 Application::ReadyToRun(void)
114 Window *window = new Window();
115 window->Show();
119 // #pragma mark -
122 int
123 main(int argc, char **argv)
125 Application app;
127 app.Run();
128 return 0;