Ticket #6185: fontHang.cpp

File fontHang.cpp, 1.2 KB (added by X512, 10 years ago)

System hanging code

Line 
1#include <Application.h>
2#include <Window.h>
3#include <View.h>
4
5/*
6Pe commands
7
8gcc fontHang.cpp -lbe -o fontHang
9fontHang
10*/
11
12class TestView : public BView
13{
14public:
15
16 TestView(BRect frame, char* name, uint32 flags): BView(frame, name, flags, B_WILL_DRAW)
17 {
18 }
19 virtual ~TestView()
20 {
21 }
22
23 virtual void Draw(BRect updateRect)
24 {
25 BFont f;
26 f.SetSize(-1);
27 SetFont(&f);
28 DrawString("String", BPoint(16, 16));
29 }
30};
31
32/*
33 * Window
34 */
35
36class TestWindow : public BWindow
37{
38private:
39 TestView* view;
40
41public:
42 TestWindow(BRect frame)
43 : BWindow(frame, "Test", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
44 {
45 view = new TestView(BRect(Bounds()), "Test", B_FOLLOW_ALL);
46 AddChild(view);
47 }
48
49 virtual bool QuitRequested()
50 {
51 be_app->PostMessage(B_QUIT_REQUESTED);
52 return BWindow::QuitRequested();
53 }
54};
55
56/*
57 Application
58 */
59
60class TestApplication : public BApplication
61{
62private:
63 TestWindow* wnd;
64
65public:
66 TestApplication() : BApplication ("application/x-vnd.Be-Test"){}
67 virtual void ReadyToRun()
68 {
69 BRect rect(32, 32, 32+128+8, 32+24+8);
70 wnd = new TestWindow(rect);
71 wnd->Show();
72 }
73};
74
75TestApplication* app;
76
77int main()
78{
79 app = new TestApplication();
80 app->Run();
81 return 0;
82}