Skip to content
Snippets Groups Projects
Commit c6b411da authored by Lars Kanis's avatar Lars Kanis
Browse files

Avoid Segfauls in lots of methods when called with nil instead of FXApp,...

Avoid Segfauls in lots of methods when called with nil instead of FXApp, FXComposite or FXWindow objects
parent ad950010
No related branches found
No related tags found
No related merge requests found
...@@ -464,7 +464,7 @@ public: ...@@ -464,7 +464,7 @@ public:
* Run popup menu while shown, until stop() or stopModal() is called. * Run popup menu while shown, until stop() or stopModal() is called.
* Also returns when entering previous cascading popup menu. * Also returns when entering previous cascading popup menu.
*/ */
FXint runPopup(FXWindow* window); FXint runPopup(FXWindow* owner);
/// True if the window is modal /// True if the window is modal
bool isModal(FXWindow* window) const; bool isModal(FXWindow* window) const;
......
...@@ -53,10 +53,10 @@ public: ...@@ -53,10 +53,10 @@ public:
public: public:
/// Construct splash window /// Construct splash window
FXSplashWindow(FXApp* ap,FXIcon* ic,FXuint opts=SPLASH_SIMPLE,FXuint ms=5000); FXSplashWindow(FXApp* a,FXIcon* ic,FXuint opts=SPLASH_SIMPLE,FXuint ms=5000);
/// Construct splash window /// Construct splash window
FXSplashWindow(FXWindow* ow,FXIcon* ic,FXuint opts=SPLASH_SIMPLE,FXuint ms=5000); FXSplashWindow(FXWindow* own,FXIcon* ic,FXuint opts=SPLASH_SIMPLE,FXuint ms=5000);
/// Set the icon for the splash window /// Set the icon for the splash window
void setIcon(FXIcon* ic); void setIcon(FXIcon* ic);
......
...@@ -24,8 +24,14 @@ ...@@ -24,8 +24,14 @@
%apply Pointer NONNULL { %apply Pointer NONNULL {
FXApp* APP, FXApp* APP,
FXComposite* PARENT, FXApp* a,
FXWindow* OWNER FXApp* app,
FXApp* application,
FXComposite* PARENT,
FXComposite* p,
FXWindow* OWNER,
FXWindow* own,
FXWindow* owner
} }
/* Type-checking rules */ /* Type-checking rules */
......
...@@ -23,6 +23,10 @@ class TC_FXApp2 < Fox::TestCase ...@@ -23,6 +23,10 @@ class TC_FXApp2 < Fox::TestCase
super(self.class.name) super(self.class.name)
end end
def test_nil_window_raises_argument_error
assert_raise(ArgumentError){ app.runPopup(nil) }
end
def check_events(pipe_rd, pipe_wr) def check_events(pipe_rd, pipe_wr)
app.addInput(pipe_wr, INPUT_WRITE, app, FXApp::ID_QUIT) app.addInput(pipe_wr, INPUT_WRITE, app, FXApp::ID_QUIT)
app.run app.run
......
...@@ -10,6 +10,10 @@ class TC_FXButton < Fox::TestCase ...@@ -10,6 +10,10 @@ class TC_FXButton < Fox::TestCase
@button = FXButton.new(mainWindow, "buttonText") @button = FXButton.new(mainWindow, "buttonText")
end end
def test_nil_parent_raises_argument_error
assert_raise(ArgumentError){ FXButton.new(nil, "buttonText") }
end
def testText def testText
assert(@button.text) assert(@button.text)
assert_instance_of(String, @button.text) assert_instance_of(String, @button.text)
......
...@@ -10,6 +10,15 @@ class TC_FXGLViewer < Fox::TestCase ...@@ -10,6 +10,15 @@ class TC_FXGLViewer < Fox::TestCase
vis = FXGLVisual.new(app, VISUAL_DOUBLEBUFFER) vis = FXGLVisual.new(app, VISUAL_DOUBLEBUFFER)
@viewer = FXGLViewer.new(mainWindow, vis) @viewer = FXGLViewer.new(mainWindow, vis)
end end
def test_supported
assert FXGLVisual.supported?(app)
end
def test_nil_app_raises_argument_error
assert_raise(ArgumentError){ FXGLVisual.supported?(nil) }
end
=begin =begin
def test_readPixels def test_readPixels
pixels = @viewer.readPixels(0, 0, @viewer.width, @viewer.height) pixels = @viewer.readPixels(0, 0, @viewer.width, @viewer.height)
......
...@@ -9,6 +9,10 @@ class TC_FXMessageBox < Fox::TestCase ...@@ -9,6 +9,10 @@ class TC_FXMessageBox < Fox::TestCase
super(self.class.name) super(self.class.name)
end end
def test_nil_app_raises_argument_error
assert_raise(ArgumentError){ FXMessageBox.new(nil, "Save?", "Save?", :opts => MBOX_SAVE_CANCEL_DONTSAVE) }
end
def test_construct_with_save_cancel_dontsave def test_construct_with_save_cancel_dontsave
assert_nothing_raised(RangeError) do assert_nothing_raised(RangeError) do
FXMessageBox.new(mainWindow, "Save?", "Save?", :opts => MBOX_SAVE_CANCEL_DONTSAVE) FXMessageBox.new(mainWindow, "Save?", "Save?", :opts => MBOX_SAVE_CANCEL_DONTSAVE)
......
...@@ -10,6 +10,10 @@ class TC_FXScrollArea < Fox::TestCase ...@@ -10,6 +10,10 @@ class TC_FXScrollArea < Fox::TestCase
@scrollArea = FXScrollArea.new(mainWindow) @scrollArea = FXScrollArea.new(mainWindow)
end end
def test_nil_parent_raises_argument_error
assert_raise(ArgumentError){ FXScrollArea.new(nil) }
end
def test_position_get def test_position_get
pos = @scrollArea.position pos = @scrollArea.position
assert_instance_of(Array, pos) assert_instance_of(Array, pos)
......
...@@ -15,6 +15,10 @@ class TC_FXShell < Test::Unit::TestCase ...@@ -15,6 +15,10 @@ class TC_FXShell < Test::Unit::TestCase
@mainWin = FXMainWindow.new(@app, 'TC_FXShell') @mainWin = FXMainWindow.new(@app, 'TC_FXShell')
end end
def test_nil_parent_raises_argument_error
assert_raise(ArgumentError){ FXShell.new(nil, 0, 0, 0, 0, 0) }
end
def test_new def test_new
# Free-floating # Free-floating
shell1 = FXShell.new(@app, 0, 0, 0, 0, 0) shell1 = FXShell.new(@app, 0, 0, 0, 0, 0)
......
...@@ -15,6 +15,10 @@ class TC_FXTopWindow < Test::Unit::TestCase ...@@ -15,6 +15,10 @@ class TC_FXTopWindow < Test::Unit::TestCase
@mainWin = FXMainWindow.new(@app, 'TC_FXButton') @mainWin = FXMainWindow.new(@app, 'TC_FXButton')
end end
def test_nil_app_raises_argument_error
assert_raise(ArgumentError){ FXTopWindow.new(nil, 'TC_FXButton') }
end
def test_new def test_new
# Free-floating # Free-floating
top1 = FXTopWindow.new(@app, "top1", nil, nil, DECOR_ALL, 0, 0, 0, 0, top1 = FXTopWindow.new(@app, "top1", nil, nil, DECOR_ALL, 0, 0, 0, 0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment