Permalink
Browse files

Avoid Segfauls in lots of methods when called with nil instead of FXA…

…pp, FXComposite or FXWindow objects
  • Loading branch information...
1 parent ad95001 commit c6b411daead333365a0524ce5518daf186107684 @larskanis committed May 31, 2012
View
@@ -464,7 +464,7 @@ public:
* Run popup menu while shown, until stop() or stopModal() is called.
* Also returns when entering previous cascading popup menu.
*/
- FXint runPopup(FXWindow* window);
+ FXint runPopup(FXWindow* owner);
/// True if the window is modal
bool isModal(FXWindow* window) const;
@@ -53,10 +53,10 @@ public:
public:
/// 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
- 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
void setIcon(FXIcon* ic);
@@ -24,8 +24,14 @@
%apply Pointer NONNULL {
FXApp* APP,
- FXComposite* PARENT,
- FXWindow* OWNER
+ FXApp* a,
+ FXApp* app,
+ FXApp* application,
+ FXComposite* PARENT,
+ FXComposite* p,
+ FXWindow* OWNER,
+ FXWindow* own,
+ FXWindow* owner
}
/* Type-checking rules */
View
@@ -23,6 +23,10 @@ def setup
super(self.class.name)
end
+ def test_nil_window_raises_argument_error
+ assert_raise(ArgumentError){ app.runPopup(nil) }
+ end
+
def check_events(pipe_rd, pipe_wr)
app.addInput(pipe_wr, INPUT_WRITE, app, FXApp::ID_QUIT)
app.run
View
@@ -10,6 +10,10 @@ def setup
@button = FXButton.new(mainWindow, "buttonText")
end
+ def test_nil_parent_raises_argument_error
+ assert_raise(ArgumentError){ FXButton.new(nil, "buttonText") }
+ end
+
def testText
assert(@button.text)
assert_instance_of(String, @button.text)
View
@@ -10,6 +10,15 @@ def setup
vis = FXGLVisual.new(app, VISUAL_DOUBLEBUFFER)
@viewer = FXGLViewer.new(mainWindow, vis)
end
+
+ def test_supported
+ assert FXGLVisual.supported?(app)
+ end
+
+ def test_nil_app_raises_argument_error
+ assert_raise(ArgumentError){ FXGLVisual.supported?(nil) }
+ end
+
=begin
def test_readPixels
pixels = @viewer.readPixels(0, 0, @viewer.width, @viewer.height)
View
@@ -9,6 +9,10 @@ def setup
super(self.class.name)
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
assert_nothing_raised(RangeError) do
FXMessageBox.new(mainWindow, "Save?", "Save?", :opts => MBOX_SAVE_CANCEL_DONTSAVE)
View
@@ -10,6 +10,10 @@ def setup
@scrollArea = FXScrollArea.new(mainWindow)
end
+ def test_nil_parent_raises_argument_error
+ assert_raise(ArgumentError){ FXScrollArea.new(nil) }
+ end
+
def test_position_get
pos = @scrollArea.position
assert_instance_of(Array, pos)
View
@@ -15,6 +15,10 @@ def setup
@mainWin = FXMainWindow.new(@app, 'TC_FXShell')
end
+ def test_nil_parent_raises_argument_error
+ assert_raise(ArgumentError){ FXShell.new(nil, 0, 0, 0, 0, 0) }
+ end
+
def test_new
# Free-floating
shell1 = FXShell.new(@app, 0, 0, 0, 0, 0)
View
@@ -15,6 +15,10 @@ def setup
@mainWin = FXMainWindow.new(@app, 'TC_FXButton')
end
+ def test_nil_app_raises_argument_error
+ assert_raise(ArgumentError){ FXTopWindow.new(nil, 'TC_FXButton') }
+ end
+
def test_new
# Free-floating
top1 = FXTopWindow.new(@app, "top1", nil, nil, DECOR_ALL, 0, 0, 0, 0,

0 comments on commit c6b411d

Please sign in to comment.