From 8b89d333413596abd148f77cee14a53708180e2e Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 12 Feb 2016 18:05:51 -0500
Subject: [PATCH] remove matju's Qt-related code

---
 pd/src/configure.in | 11 ------
 pd/src/g_canvas.h   |  4 ---
 pd/src/g_qt.cpp     | 81 ---------------------------------------------
 pd/src/g_qt.h       | 29 ----------------
 pd/src/g_template.c |  6 ++--
 pd/src/makefile.in  | 31 -----------------
 pd/src/s_inter.c    | 18 ----------
 pd/src/s_main.c     | 21 ------------
 pd/src/s_stuff.h    |  3 --
 9 files changed, 3 insertions(+), 201 deletions(-)
 delete mode 100644 pd/src/g_qt.cpp
 delete mode 100644 pd/src/g_qt.h

diff --git a/pd/src/configure.in b/pd/src/configure.in
index 50efa119e..406a47f8e 100644
--- a/pd/src/configure.in
+++ b/pd/src/configure.in
@@ -11,7 +11,6 @@ AC_SUBST(portmidi, no)
 AC_SUBST(binarymode, -m755)
 AC_SUBST(fftw, no)
 AC_SUBST(tk, yes)
-AC_SUBST(qt, no)
 AC_SUBST(PDLIB)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(MORECFLAGS)
@@ -55,8 +54,6 @@ AC_ARG_ENABLE(fat,      [  --disable-fat           build fat binary on Mac OS X]
     fat=$enableval, fat="yes")
 AC_ARG_ENABLE(tk,       [  --disable-tk            build without tcl/tk-GUI],
     tk=$enableval)
-AC_ARG_ENABLE(qt,       [  --enable-qt             build with Qt (not implemented)],
-    qt=$enableval)
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -459,14 +456,6 @@ AC_TRY_LINK( [
 fi
 ## }JMZ: end of large-file support section
 
-
-if test x$qt != "xno"; then
-dnl Some kind of AC_CHECK_HEADER should go here.
-dnl Some kind of AC_CHECK_LIB    should go here.
-CPPFLAGS=$CPPFLAGS" -DQTGUI"
-fi
-
-
 if test -d ../obj
 then echo -n
 else mkdir ../obj
diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h
index 1d32a0981..cd38af65d 100644
--- a/pd/src/g_canvas.h
+++ b/pd/src/g_canvas.h
@@ -770,10 +770,6 @@ EXTERN void *canvas_undo_set_font(t_canvas *x, int font);
 /* ------------------------------- */
 
 
-/* ---------- interface to Qt (libQt5) with threads -------------------- */
-
-void *qt_thread_main (void *);
-
 /* ---------- other things added by Mathieu (aug.2014) ----------------- */
 
 void canvas_raise_all_cords (t_canvas *x);
diff --git a/pd/src/g_qt.cpp b/pd/src/g_qt.cpp
deleted file mode 100644
index 036e920d7..000000000
--- a/pd/src/g_qt.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <stdio.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QLabel>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMessageBox>
-#include <QtGui/QtGui>
-#include "g_qt.h"
-
-int tv_ms_diff (timeval &a, timeval &b) {
-  return (a.tv_sec-b.tv_sec)*1000 + (a.tv_usec-b.tv_usec)/1000;
-}
-
-static void infinite_loop () {
-	timeval t0,t1;
-	gettimeofday(&t0,0);
-	for (;;) {
-		gettimeofday(&t1,0);
-		fprintf(stderr, "Qt thread running... (%d s)\n", tv_ms_diff(t1,t0));
-		sleep(2);
-	}
-}
-
-void *qt_thread_main (void *) {
-	int argc=0; char **argv=0;
-	QApplication app(argc,argv);
-	app.setApplicationName("PureData L2ork for Qt");
-	setlocale(LC_NUMERIC,"C"); //HACK because QApplication constructor sets LC_NUMERIC while pd assumes a C locale.
-	MainWindow mainWin;
-	mainWin.show();
-	app.exec();
-	fprintf(stderr,"qt_thread_main EXITING\n");
-	return 0;
-}
-
-#define MENUITEM(MENU,ACT,TEXT,FUNC) \
-	ACT = new QAction(tr(TEXT), this); \
-	connect(ACT, SIGNAL(triggered()), this, SLOT(FUNC)); \
-	MENU->addAction(ACT);
-
-MainWindow::MainWindow () {
-	QLabel *l = new QLabel("Hello Data Flowers");
-	l->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
-	setCentralWidget(l);
-
-	fileMenu = menuBar()->addMenu(tr("&File"));
-	MENUITEM(fileMenu,quitAct,"Quit",close());
-
-	editMenu = menuBar()->addMenu(tr("&Edit"));
-	MENUITEM(editMenu,editModeAct,"&Edit mode",editMode());
-
-	menuBar()->addSeparator();
-	helpMenu = menuBar()->addMenu(tr("&Help"));
-	MENUITEM(helpMenu,aboutAct,"&About",about());
-}
-
-void MainWindow::about () {
-	QMessageBox::about(this, tr("About PureData L2ork"),
-		tr("<b>PureData</b> is an app whose purpose is to turn bits into potentially different bits."));
-}
-
-void MainWindow::editMode () {
-	QMessageBox::about(this, tr("Edit Mode"),
-		tr("To toggle edit mode, please implement this feature and recompile."));
-}
-
-bool MainWindow::askQuit () {
-	return QMessageBox::Ok == QMessageBox::warning(this, tr("Quit"),
-		tr("This will close Qt but leave Tk windows open. Proceed ?"), QMessageBox::Ok | QMessageBox::Cancel);
-}
-
-//void MainWindow::quit () {if (askQuit()) ...}
-
-void MainWindow::closeEvent(QCloseEvent *event) {
-	if (askQuit()) event->accept(); else event->ignore();
-}
diff --git a/pd/src/g_qt.h b/pd/src/g_qt.h
deleted file mode 100644
index 8833327ba..000000000
--- a/pd/src/g_qt.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// this file is for MOC/Qt stuff.
-// Do not include in C source.
-// the C interface to g_qt.c will be in g_canvas.h.
-
-#include <QtWidgets/QMainWindow>
-
-class MainWindow : public QMainWindow {
-	Q_OBJECT
-public:
-	MainWindow();
-	bool askQuit();
-	void closeEvent(QCloseEvent *event);
-
-	// list of menus
-	QMenu *fileMenu;
-	QMenu *editMenu;
-	QMenu *helpMenu;
-
-	// list of actions connecting menus/buttons to slots
-	QAction *quitAct;
-	QAction *editModeAct;
-	QAction *aboutAct;
-
-public slots:
-	// list of functions called by menus or buttons
-	//void quit ();
-	void editMode ();
-	void about ();
-};
diff --git a/pd/src/g_template.c b/pd/src/g_template.c
index 983c71296..81b201996 100644
--- a/pd/src/g_template.c
+++ b/pd/src/g_template.c
@@ -1073,9 +1073,9 @@ t_class *svg_class;
       string for that option.  There's still the bug that the user can't set
       an attribute back to "inherit" after they've set something explicitly,
       however.
-   2) This might be generally useful even with Qt, so that if the user calls
-      a method for an attribute without any arguments, Qt goes back to
-      inheriting the value from the parent.  That gives us a way to
+   2) This might be generally useful even with other GUI toolkits, so that if
+      the user calls a method for an attribute without any arguments, Qt goes
+      back to inheriting the value from the parent.  That gives us a way to
       differentiate "inherit" from fielddescriptors, the value "none" and
       "".  (Similar to the way "set" resets a message box.)
 */
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index 0defb229a..b6143768a 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -49,8 +49,6 @@ ARCH_CFLAGS = -DPD
 
 CFLAGS = @CFLAGS@ $(ARCH_CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(MORECFLAGS)
 
-QTGUI = @qt@
-
 # the sources
 
 SYSSRC += @SYSSRC@
@@ -87,10 +85,6 @@ TYPE_PUNNING_OBJ = $(TYPE_PUNNING_SRC:.c=.o)
 OPT_SAFE_OBJ = $(OPT_SAFE_SRC:.c=.o) 
 OBJ = $(SRC:.c=.o) 
 
-ifeq ($(QTGUI), yes)
-	OBJ += g_qt.moc.o g_qt.o
-endif
-
 GSRC =  @GUISRC@
 
 GOBJ = $(GSRC:.c=.o)
@@ -109,16 +103,6 @@ ifneq ($(PD_TEST_VERSION),)
 	PD_VERSION := $(PD_VERSION)-$(PD_TEST_VERSION)
 endif
 
-# C++/Qt
-CXX = g++
-CXXFLAGS =
-MOC = moc
-QT_INCLUDE = -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore
-ifeq ($(QTGUI),yes)
-  LDFLAGS += -L/usr/lib/i386-linux-gnu
-  LIB += -lQt5Core -lQt5Gui -lQt5Widgets
-endif
-
 #
 #  ------------------ targets ------------------------------------
 #
@@ -144,15 +128,6 @@ $(GOBJ) : %.o : %.c
 $(ASIOOBJ): %.o : %.cpp
 	$(CXX) $(CFLAGS) $(INCLUDE) -c -o $(OBJ_DIR)/$*.o $*.cpp
 
-../obj/g_qt.moc.cpp : g_qt.h
-	$(MOC) $(subst $(CPPFLAGS),-fno-strict-aliasing,) $(QT_INCLUDE) $< -o ../obj/$@
-
-../obj/g_qt.moc.o : ../obj/g_qt.moc.cpp
-	$(CXX) $(CFLAGS) $(CXXFLAGS) $(QT_INCLUDE) -fPIC -c ../obj/g_qt.moc.cpp -o ../obj/g_qt.moc.o
-
-../obj/g_qt.o : g_qt.cpp
-	$(CXX) $(CFLAGS) $(CXXFLAGS) $(QT_INCLUDE) -fPIC -c g_qt.cpp -o ../obj/g_qt.o
-
 pd: $(PDEXEC)
 
 ifneq ($(GSRC),)
@@ -177,13 +152,8 @@ $(BIN_DIR)/pdsend: u_pdsend.c
 $(BIN_DIR)/pdreceive: u_pdreceive.c $(BIN_DIR)
 	$(CC) $(CFLAGS)  $(STRIPFLAG) -o $(BIN_DIR)/pdreceive u_pdreceive.c
 
-ifeq ($(QTGUI),yes)
-$(PDEXEC): $(OBJ)
-	cd ../obj;  $(CXX) $(LDFLAGS) $(DBG_CFLAGS) -o $(PDEXEC) $(OBJ) $(LIB)
-else
 $(PDEXEC): $(OBJ)
 	cd ../obj;  $(CC) $(LDFLAGS) $(DBG_CFLAGS) -o $(PDEXEC) $(OBJ) $(LIB)
-endif
 
 $(BIN_DIR)/pd-gui: $(GOBJ) $(GSRC)
 	cd ../obj; $(CC) $(INCLUDE) -o $(BIN_DIR)/$(GUINAME) $(GOBJ) $(GLIB)
@@ -309,7 +279,6 @@ install: all tkpath tkdnd
 	@echo "Pd install succeeded."
 
 local-clean:	
-	-rm -f -- ../obj/*.moc.cpp
 	-rm -f -- $(OBJ)
 	-rm -f ../obj/* $(PDEXEC) $(BIN_DIR)/$(GUINAME) $(BIN_DIR)/pdsend \
 	    $(BIN_DIR)/pdreceive $(BIN_DIR)/pd-watchdog m_stamp.c
diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index e1e54c1ef..6074974e2 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -118,11 +118,6 @@ static t_binbuf *inbinbuf;
 static t_socketreceiver *sys_socketreceiver;
 extern int sys_addhist(int phase);
 
-#ifdef QTGUI
-pthread_t sys_thread_main;
-pthread_t sys_thread_qt;
-#endif
-
 /* ----------- functions for timing, signals, priorities, etc  --------- */
 
 #ifdef MSW
@@ -1113,15 +1108,6 @@ static int defaultfontshit[MAXFONTS] = {
         24, 15, 28};
 #define NDEFAULTFONT (sizeof(defaultfontshit)/sizeof(*defaultfontshit))
 
-
-#ifdef QTGUI
-void sys_start_qt () {
-	sys_thread_main = pthread_self();
-	int r = pthread_create(&sys_thread_qt,0,qt_thread_main,0);
-	if (r) fprintf(stderr,"pthread_create: %s",strerror(r));
-}
-#endif
-
 int sys_startgui(const char *guidir)
 {
     pid_t childpid;
@@ -1423,10 +1409,6 @@ fprintf(stderr, "guidir is %s\n", guidir);
 
 #endif /* MSW */
     }
-    
-#ifdef QTGUI
-	if (sys_qtcanvas) sys_start_qt();
-#endif
 
 #if defined(__linux__) || defined(IRIX)
         /* now that we've spun off the child process we can promote
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 82e092d3c..091b256f2 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -54,11 +54,6 @@ int sys_unique = 0;     /* by default off, prevents multiple instances
                            of pd-l2ork */
 int sys_legacy = 0;     /* by default off, used to enable legacy features,
                            such as offsets in iemgui object positioning */
-
-#ifdef QTGUI
-int sys_qtcanvas = 0; /* enable Qt */
-#endif
-
 char *sys_guicmd;
 t_symbol *sys_libdir;
 t_symbol *sys_guidir;
@@ -439,15 +434,6 @@ static char *(usagemessage[]) = {
 "\n",
 };
 
-#ifdef QTGUI
-//   -nogui applies only to Tk.
-//   -qtcanvas should open a Qt window for every pd canvas (two toolkits at once)
-//   more options could go here, to enable a Qt main window, menus, dialogues.
-//   those are transitory options, until Tk is removed, at which point
-//   -nogui will apply to Qt, -guiport and -guiport will be removed, and
-//   all transitory options will be removed.
-#endif
-
 static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
 {
     int n = 0;
@@ -872,13 +858,6 @@ int sys_argparse(int argc, char **argv)
             sys_guicmd = argv[1];
             argc -= 2; argv += 2;
         }
-#ifdef QTGUI
-        else if (!strcmp(*argv, "-qtcanvas"))
-		{
-			sys_qtcanvas = 1;
-			argc--; argv++;
-		}
-#endif
         else if (!strcmp(*argv, "-send") && argc > 1)
         {
             sys_messagelist = namelist_append(sys_messagelist, argv[1], 1);
diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h
index d9f77a0a5..5575819b2 100644
--- a/pd/src/s_stuff.h
+++ b/pd/src/s_stuff.h
@@ -47,9 +47,6 @@ extern int sys_verbose;
 extern int sys_noloadbang;
 extern int sys_nogui;
 extern char *sys_guicmd;
-#ifdef QTGUI
-extern int sys_qtcanvas;
-#endif
 
 EXTERN int sys_nearestfontsize(int fontsize);
 EXTERN int sys_hostfontsize(int fontsize);
-- 
GitLab