Skip to content

Commit

Permalink
Make all dialogs modal by default if using intel or binary amd driver…
Browse files Browse the repository at this point in the history
… on linux (to avoid crashes)
  • Loading branch information
kmatheussen committed Jul 21, 2015
1 parent a0d334a commit 98b7d81
Show file tree
Hide file tree
Showing 29 changed files with 256 additions and 85 deletions.
5 changes: 1 addition & 4 deletions OpenGL/Render.cpp
Expand Up @@ -20,10 +20,7 @@

#include "GfxElements.h"

extern "C" {
typedef struct PyObject_ PyObject;
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"

#include "Render_proc.h"

Expand Down
9 changes: 9 additions & 0 deletions OpenGL/Widget.cpp
Expand Up @@ -71,6 +71,12 @@ void GL_unlock(void){
mutex.unlock();
}

static bool g_should_do_modal_windows = false;

bool GL_should_do_modal_windows(void){
return g_should_do_modal_windows;
}

static QSemaphore g_order_make_current;
static QSemaphore g_ack_make_current;

Expand Down Expand Up @@ -900,6 +906,8 @@ QWidget *GL_create_widget(QWidget *parent){
);
if (result==1)
SETTINGS_write_bool("show_catalyst_gfx_message_during_startup", false);

g_should_do_modal_windows = true;
}


Expand Down Expand Up @@ -975,6 +983,7 @@ QWidget *GL_create_widget(QWidget *parent){
SETTINGS_write_bool("show_intel_gfx_message2_during_startup", false);
}

g_should_do_modal_windows = true;
show_mesa_warning = false;
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions OpenGL/Widget_proc.h
Expand Up @@ -12,6 +12,8 @@
extern "C" {
#endif

extern bool GL_should_do_modal_windows(void);

extern void GL_EnsureMakeCurrentIsCalled(void);

extern void GL_erase_estimated_vblank(void);
Expand Down
5 changes: 1 addition & 4 deletions Qt/Qt_EventReceiver.cpp
Expand Up @@ -51,10 +51,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "../OpenGL/Render_proc.h"
#include "../OpenGL/Widget_proc.h"

extern "C" {
struct PyObject;
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"


#if USE_GTK_VISUAL
Expand Down
4 changes: 1 addition & 3 deletions Qt/Qt_Main.cpp
Expand Up @@ -51,9 +51,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "../common/OS_settings_proc.h"
#include "../common/OS_visual_input.h"

extern "C" {
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"

#include "../mixergui/QM_MixerWidget.h"

Expand Down
11 changes: 2 additions & 9 deletions Qt/Qt_MainWindow.cpp
Expand Up @@ -14,10 +14,8 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

extern "C"{
#include "../common/includepython.h"
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"

#include <QApplication>
#include <QMainWindow>
Expand Down Expand Up @@ -635,12 +633,7 @@ int GFX_Message(vector_t *buttons, QString message){

}


num_users_of_keyboard++;
{
safeExec(msgBox);
}
num_users_of_keyboard--;
safeExec(msgBox);

QAbstractButton *clicked_button = msgBox.clickedButton();

Expand Down
15 changes: 10 additions & 5 deletions Qt/Qt_check_for_updates.cpp
Expand Up @@ -7,6 +7,9 @@

#include "../common/nsmtracker.h"

#include "../OpenGL/Widget_proc.h"



static bool getVersionNumbers(QString versionString, int &major, int &minor, int &revision){
QStringList list = versionString.split(".");
Expand Down Expand Up @@ -44,11 +47,13 @@ static void maybeInformAboutNewVersion(QString newestversion = "3.5.1"){

if (hasNewer(newestversion, VERSION)) {
printf("Version %s of Radium is available for download at http://users.notam02.no/~kjetism/radium (%s)\n", newestversion.toUtf8().constData(), VERSION);
QMessageBox::information(NULL,
"Hello!",
"You are running Radium V" VERSION ".<p>"
"A newer version (V" + newestversion + ") is available for download at <A href=\"http://users.notam02.no/~kjetism/radium\">http://users.notam02.no/~kjetism/radium</a>"
);
GL_lock();{
QMessageBox::information(NULL,
"Hello!",
"You are running Radium V" VERSION ".<p>"
"A newer version (V" + newestversion + ") is available for download at <A href=\"http://users.notam02.no/~kjetism/radium\">http://users.notam02.no/~kjetism/radium</a>"
);
}GL_unlock();
} else
printf("Nope, %s is actually newer than (or just as old) as %s\n", VERSION, newestversion.toUtf8().constData());
}
Expand Down
10 changes: 2 additions & 8 deletions Qt/Qt_comment_dialog_callbacks.cpp
Expand Up @@ -67,21 +67,15 @@ static void ensure_widget_is_created(void){
if(widget==NULL){
widget = new comment_dialog(NULL);
widget->setWindowFlags(Qt::WindowStaysOnTopHint);
widget->setWindowModality(Qt::ApplicationModal);
//widget->setWindowModality(Qt::ApplicationModal);
}
}

extern "C"{
void COMMENTDIALOG_open(void){
ensure_widget_is_created();

safeShow(widget);

/*
num_users_of_keyboard++;
widget->exec();
num_users_of_keyboard--;
*/
safeShowOrExec(widget);
}

bool COMMENT_show_after_loading(void){
Expand Down
6 changes: 2 additions & 4 deletions Qt/Qt_instruments.cpp
Expand Up @@ -14,10 +14,8 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

extern "C"{
#include "../common/includepython.h"
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"


#include <qspinbox.h>

Expand Down
10 changes: 5 additions & 5 deletions Qt/Qt_mixer_widget_callbacks.h
Expand Up @@ -139,10 +139,10 @@ class Mixer_widget : public QWidget, public Ui::Mixer_widget{
}

void on_help_button_clicked(){
QMessageBox msgBox;
static QMessageBox *msgBox = new QMessageBox;

msgBox.setText("Mixer Interface");
msgBox.setInformativeText(
msgBox->setText("Mixer Interface");
msgBox->setInformativeText(
"* Move objects with right mouse button.\n"
"\n"
"* Double-click the name of an object to open GUI.\n"
Expand All @@ -161,9 +161,9 @@ class Mixer_widget : public QWidget, public Ui::Mixer_widget{
"\n"
"* Zoom in and out by pressing CTRL and using the scroll wheel.\n"
);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox->setStandardButtons(QMessageBox::Ok);

safeExec(msgBox);
safeShowOrExec(msgBox);
}

};
Expand Down
4 changes: 1 addition & 3 deletions Qt/Qt_pianorollheader_callbacks.h
Expand Up @@ -12,9 +12,7 @@
#include "../common/OS_visual_input.h"
#include "../OpenGL/Widget_proc.h"

extern "C" {
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"

#include "Qt_MyQButton.h"

Expand Down
2 changes: 1 addition & 1 deletion Qt/Qt_plugin_widget_callbacks.h
Expand Up @@ -245,7 +245,7 @@ class Plugin_widget : public QWidget, public Ui::Plugin_widget{
else
infoBox.setText("No information about this plugin."); // This message box should never show.

safeShow(&infoBox);
safeShowOrExec(&infoBox);
}
};

Expand Down
25 changes: 14 additions & 11 deletions Qt/Qt_preferences_callbacks.cpp
Expand Up @@ -32,10 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "../midi/midi_i_plugin_proc.h"
#include "../midi/midi_menues_proc.h"

extern "C" {
struct PyObject;
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"

#include "../Qt/Qt_MyQSpinBox.h"
#include <FocusSniffers.h>
Expand All @@ -49,6 +46,7 @@ extern "C" {

extern struct Root *root;


namespace{

class Preferences : public QDialog, public Ui::Preferences {
Expand Down Expand Up @@ -131,6 +129,11 @@ class Preferences : public QDialog, public Ui::Preferences {
showBarsAndBeats->setChecked(true);
}

// Windows
{
modal_windows->setChecked(doModalWindows());
}

// MIDI
{
const char *name = MIDI_get_input_port();
Expand Down Expand Up @@ -232,6 +235,12 @@ public slots:
setLinenumbersVisible(val);
}

// windows

void on_modal_windows_toggled(bool val){
setModalWindows(val);
}

// MIDI

void on_set_input_port_clicked(){
Expand Down Expand Up @@ -267,13 +276,7 @@ void PREFERENCES_open(void){
//widget->setWindowModality(Qt::ApplicationModal);
}

safeShow(g_preferences_widget);

/*
num_users_of_keyboard++;
safeExec(msgBox);
num_users_of_keyboard--;
*/
safeShowOrExec(g_preferences_widget);
}

void PREFERENCES_open_MIDI(void){
Expand Down
16 changes: 7 additions & 9 deletions Qt/Qt_tools_callbacks.cpp
Expand Up @@ -14,11 +14,15 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

#include "mQt_tools_callbacks.h"

//#include "../common/nsmtracker.h"

#include "helpers.h"

struct Root;
extern struct Root *root;

#include "mQt_tools_callbacks.h"


extern int num_users_of_keyboard;

Expand All @@ -30,13 +34,7 @@ void TOOLS_open(void){
//widget->setWindowModality(Qt::ApplicationModal);
}

safeShow(widget);

/*
num_users_of_keyboard++;
widget->exec();
num_users_of_keyboard--;
*/
safeShowOrExec(widget);
}


Expand Down
4 changes: 1 addition & 3 deletions Qt/Qt_tools_callbacks.h
Expand Up @@ -12,9 +12,7 @@
#include "../common/OS_visual_input.h"
#include "../OpenGL/Widget_proc.h"

extern "C" {
#include "../api/radium_proc.h"
}
#include "../api/api_proc.h"

#include "Qt_MyQButton.h"

Expand Down
1 change: 1 addition & 0 deletions Qt/compressor_vertical_sliders.cpp
Expand Up @@ -15,6 +15,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

//#include <string>
#include <math.h>

#define GLIDING_PEAK_AREA 0 // Set to 1 to get gliding peaks area, which most meters use. Looks good, but I think it is slightly more confusing than the array used now.

Expand Down
28 changes: 27 additions & 1 deletion Qt/helpers.h
Expand Up @@ -5,37 +5,63 @@

#include "../OpenGL/Widget_proc.h"

#include "../api/api_proc.h"


extern int num_users_of_keyboard;


static inline int safeExec(QMessageBox *widget){
int ret;

num_users_of_keyboard++;
GL_lock();{
ret = widget->exec();
}GL_unlock();
num_users_of_keyboard--;

return ret;
}

static inline int safeExec(QMessageBox &widget){
int ret;

num_users_of_keyboard++;
GL_lock();{
ret = widget.exec();
}GL_unlock();
num_users_of_keyboard--;

return ret;
}

static inline int safeExec(QDialog *widget){
int ret;

num_users_of_keyboard++;
GL_lock();{
ret = widget->exec();
}GL_unlock();
num_users_of_keyboard--;

return ret;
}

static inline void safeShow(QWidget *widget){
static inline void safeShow(QWidget *widget){
GL_lock(); {
widget->show();
widget->raise();
widget->activateWindow();
}GL_unlock();
}



static inline void safeShowOrExec(QDialog *widget){
if (doModalWindows())
safeExec(widget);
else
safeShow(widget);
}

#endif // RADIUM_QT_HELPERS

0 comments on commit 98b7d81

Please sign in to comment.