Skip to content

Commit c34353c

Browse files
Merge pull request #91 from summer-alice/gtk_fix_nullDereference
[gtk] Fix null dereference in Display
2 parents 7581565 + 4615938 commit c34353c

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@ jobs:
2626
- dmd-2.085.1
2727
- dmd-2.090.1
2828
arch: [x86_64]
29+
buildType: [unittest]
2930
include:
3031
- os: windows-2019
3132
dc: dmd-latest
3233
arch: x86
3334
- os: windows-2019
3435
dc: ldc-latest
3536
arch: x86
37+
- os: ubuntu-20.04
38+
dc: dmd-latest
39+
arch: x86_64
40+
buildType: optimized-unittests
41+
- os: ubuntu-20.04
42+
dc: ldc-latest
43+
arch: x86_64
44+
buildType: optimized-unittests
3645
runs-on: ${{ matrix.os }}
3746
steps:
3847
- name: Checkout Repository
@@ -62,9 +71,9 @@ jobs:
6271
libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxrandr-dev \
6372
libxrender-dev libxtst-dev
6473
65-
- name: Test DWT Gtk
74+
- name: Test DWT Gtk (${{ matrix.buildType }})
6675
if: ${{ matrix.os == 'ubuntu-20.04' }}
6776
uses: GabrielBB/xvfb-action@v1 # X virtual framebuffer
6877
with:
6978
working-directory: ./
70-
run: dub test -c unittest-gtk
79+
run: dub test -c unittest-gtk -b ${{ matrix.buildType }}

dub.sdl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ configuration "windows-win32" {
6767
dependency ":base" version="*"
6868
}
6969

70-
# Test configurations
70+
# unittest settings
71+
buildType "optimized-unittests" {
72+
buildOptions "optimize" "unittests"
73+
}
74+
7175
configuration "unittest-gtk" {
7276
platforms "linux"
7377

org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Display.d

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -920,28 +920,19 @@ protected override void create (DeviceData data) {
920920
if (Default is null) Default = this;
921921
}
922922

923-
private static extern(C) int XErrorHandler( void*, XErrorEvent* ){
924-
getDwtLogger().error ( __FILE__, __LINE__, "*** XError" );
925-
byte* p;
926-
*p = 3;
927-
return 0;
928-
}
929-
930923
void createDisplay (DeviceData data) {
931924
/* Required for g_main_context_wakeup */
932925
if (!OS.g_thread_supported ()) {
933926
OS.g_thread_init (null);
934927
}
935928
OS.gtk_set_locale();
936-
int cnt = 2;
937-
auto args = [ "name".ptr, "--sync".ptr, "".ptr ];
938-
auto a = args.ptr;
939-
if (!OS.gtk_init_check (&cnt, &a )) {
929+
// DWT: Needed to pass int* to gtk_init_check
930+
int argc = 0;
931+
if (!OS.gtk_init_check (&argc, null)) {
932+
SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]");
940933
}
941-
assert( cnt is 1 );
942934
if (OS.GDK_WINDOWING_X11 ()) xDisplay = cast(void*) OS.GDK_DISPLAY ();
943935

944-
OS.XSetErrorHandler( &Display.XErrorHandler );
945936
char* ptr = OS.gtk_check_version (MAJOR, MINOR, MICRO);
946937
if (ptr !is null) {
947938
char [] buffer = fromStringz(ptr);
@@ -4287,4 +4278,3 @@ package struct CallbackData {
42874278
Display display;
42884279
void* data;
42894280
}
4290-

0 commit comments

Comments
 (0)