1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-25 04:37:22 +01:00

* InterfaceDialog.cpp (InterfaceDialog::validate): fixes #1221

warning dialogs for the incorrect interface name would not go
away.  If user entered incorrect name of the
subinterace (e.g. name that is not a valid VLAN subinterface name)
the GUI would pop up warning dialog infinitely.
This commit is contained in:
Vadim Kurland 2010-02-10 23:46:54 +00:00
parent bd08467dde
commit 927d21cb8f
10 changed files with 203 additions and 85 deletions

View File

@ -1 +1 @@
#define BUILD_NUM 2508
#define BUILD_NUM 2511

View File

@ -1,5 +1,11 @@
2010-02-10 vadim <vadim@vk.crocodile.org>
* InterfaceDialog.cpp (InterfaceDialog::validate): fixes #1221
warning dialogs for the incorrect interface name would not go
away. If user entered incorrect name of the
subinterace (e.g. name that is not a valid VLAN subinterface name)
the GUI would pop up warning dialog infinitely.
* ../src/gui/ProjectPanel_events.cpp (ProjectPanel::event): this
change attempts to fix a bug that causes main menu item Edit /
Paste (keyboard shortcut Ctrl-V) to stop working. The bug is hard

View File

@ -43,7 +43,7 @@
#include <qcombobox.h>
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <QApplication>
#include <QUndoStack>
#include <memory>
@ -113,22 +113,33 @@ void AddressRangeDialog::validate(bool *res)
InetAddr(m_dialog->rangeStart->text().toLatin1().constData());
} catch (FWException &ex)
{
*res=false;
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->rangeStart->text()),
tr("&Continue"), 0, 0,
0 );
*res = false;
// show warning dialog only if app has focus
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->rangeStart->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
try
{
InetAddr(m_dialog->rangeEnd->text().toLatin1().constData());
} catch (FWException &ex)
{
*res=false;
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->rangeEnd->text()),
tr("&Continue"), 0, 0,
0 );
*res = false;
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->rangeEnd->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
}

View File

@ -43,6 +43,7 @@
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <QtDebug>
#include <QApplication>
#include <iostream>
@ -145,12 +146,17 @@ void IPv4Dialog::validate(bool *result)
InetAddr( m_dialog->address->text().toLatin1().constData() );
} catch (FWException &ex)
{
*result=false;
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
*result = false;
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
if (showNetmask)
@ -161,11 +167,16 @@ void IPv4Dialog::validate(bool *result)
} catch (FWException &ex)
{
*result = false;
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()),
tr("&Continue"), 0, 0,
0 );
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
}
}

View File

@ -51,6 +51,7 @@
#include <qapplication.h>
#include <qcursor.h>
#include <QUndoStack>
#include <QApplication>
#include <iostream>
@ -154,11 +155,16 @@ void IPv6Dialog::validate(bool *res)
InetAddr(AF_INET6, m_dialog->address->text().toLatin1().constData() );
} catch (FWException &ex)
{
*res=false;
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
*res = false;
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
if ( showNetmask )
@ -170,11 +176,16 @@ void IPv6Dialog::validate(bool *res)
if (!ok) throw FWException("");
} catch (FWException &ex)
{
*res=false;
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()),
tr("&Continue"), 0, 0,
0 );
*res = false;
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
}
}

View File

@ -66,6 +66,7 @@
#include <QtDebug>
#include <QTime>
#include <QUndoStack>
#include <QApplication>
using namespace std;
using namespace libfwbuilder;
@ -375,12 +376,17 @@ void InterfaceDialog::validate(bool *res)
if (obj_name.indexOf(' ') != -1 || obj_name.indexOf('-') != -1)
{
QMessageBox::critical(
this,"Firewall Builder",
tr("Interface name can not contain white space and '-'"),
tr("&Continue"), QString::null,QString::null,
0, 1 );
*res = false;
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this,"Firewall Builder",
tr("Interface name can not contain white space and '-'"),
tr("&Continue"), QString::null,QString::null,
0, 1 );
blockSignals(false);
}
return;
}
@ -391,12 +397,33 @@ void InterfaceDialog::validate(bool *res)
QString err;
if ( ! int_prop->validateInterface(obj->getParent(), obj_name, err))
{
/*
* Here is the annoying part: if user entered interface name
* that does not pass checks in interfaceProperties, this
* dialog will pop warning dialog to tell them this every time
* the dialog loses focus even if they did not change
* anything. This happens when they click on any other part of
* the GUI or even switch to another application. For example
* this happens when user adds subinterface to an interface
* with intention to make the subint a vlan. The new interface
* object is created with default name, when they change the
* name to, say, eth0 (and the parent is eth0), this causes
* the error message to appear when they switch the focus. If
* they switch to another application while cursor was in the
* object name field, the pop-up appears as well.
*/
*res = false;
QMessageBox::critical(
this,"Firewall Builder",
err,
tr("&Continue"), QString::null,QString::null,
0, 1 );
// show warning dialog only if app has focus
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this,"Firewall Builder",
err,
tr("&Continue"), QString::null,QString::null,
0, 1 );
blockSignals(false);
}
}
delete int_prop;

View File

@ -50,6 +50,7 @@
#include <qpushbutton.h>
#include <QUndoStack>
#include <QtDebug>
#include <QApplication>
using namespace std;
@ -129,11 +130,16 @@ void NetworkDialog::validate(bool *result)
} catch (FWException &ex)
{
*result = false;
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
return;
}
@ -171,12 +177,17 @@ void NetworkDialog::validate(bool *result)
// permit netmask 0.0.0.0 if the address is also 0.0.0.0
if (addr.isAny()) return;
{
// Do not allow netmask of 0 bits See #251
QMessageBox::critical(
this, "Firewall Builder",
tr("Network object should not have netmask '0.0.0.0'"),
tr("&Continue"), 0, 0,
0 );
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
// Do not allow netmask of 0 bits See #251
QMessageBox::critical(
this, "Firewall Builder",
tr("Network object should not have netmask '0.0.0.0'"),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
return;
}
}
@ -184,12 +195,17 @@ void NetworkDialog::validate(bool *result)
} catch (FWException &ex)
{
*result=false;
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg( m_dialog->netmask->text() ),
tr("&Continue"), 0, 0,
0 );
*result = false;
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg( m_dialog->netmask->text() ),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
}

View File

@ -50,6 +50,7 @@
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <QUndoStack>
#include <QApplication>
using namespace std;
@ -125,11 +126,16 @@ void NetworkDialogIPv6::validate(bool *res)
} catch (FWException &ex)
{
*res = false;
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IPv6 address '%1'").arg(
m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IPv6 address '%1'").arg(
m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
bool ok = false;
@ -142,11 +148,16 @@ void NetworkDialogIPv6::validate(bool *res)
else
{
*res = false;
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(
m_dialog->netmask->text() ),
tr("&Continue"), 0, 0,
0 );
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(
m_dialog->netmask->text() ),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
}
}

View File

@ -52,7 +52,7 @@
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <QUndoStack>
#include <QApplication>
using namespace std;
using namespace libfwbuilder;
@ -179,13 +179,17 @@ void RuleSetDialog::validate(bool *res)
if (!rx.exactMatch(m_dialog->obj_name->text()))
{
*res = false ;
QMessageBox::critical(
this,
"Firewall Builder",
tr("Rule set name '%1' is invalid. Only '[a-z][A-Z][0-9]_-+=@%^' characters are allowed.").arg( m_dialog->obj_name->text() ),
tr("&Continue"), 0, 0,
0 );
if (QApplication::focusWidget() != NULL)
{
blockSignals(true);
QMessageBox::critical(
this,
"Firewall Builder",
tr("Rule set name '%1' is invalid. Only '[a-z][A-Z][0-9]_-+=@%^' characters are allowed.").arg( m_dialog->obj_name->text() ),
tr("&Continue"), 0, 0,
0 );
blockSignals(false);
}
return ;
}
}

View File

@ -37,11 +37,11 @@
#include <qnamespace.h>
#include <QHostInfo>
#include <qhostaddress.h>
#include <qapplication.h>
#include <qpixmapcache.h>
//Added by qt3to4:
#include <QList>
#include <QPixmap>
#include <QApplication>
#include "FWBSettings.h"
@ -234,12 +234,33 @@ bool validateName(QWidget *parent, FWObject *obj, const QString &newname)
if (QString(o1->getName().c_str()) == newname)
{
QMessageBox::warning(
parent, "Firewall Builder",
QObject::tr("Object with name '%1' already exists, "
"please choose different name.").
arg(o1->getName().c_str()),
QObject::tr("&Continue"), NULL, NULL, 0, 2 );
/*
* when we open this warning dialog, the dialog class
* loses focus and obj_name lineEdit widget sends signal
* "editingfinished" again. To the user this looks like the
* warning dialog popped up twice (in fact two copies of the
* same warning dialog appear at the same time, one exactly on
* top of another). To avoid this, block signals for the
* duration while we show the dialog. Note that documentation
* does not mention that QObject::blockSignals() affects not
* only the widget but all its children, but it seems to work
* that way. Tested with Qt 4.6.1. See #1171
*/
// show warning dialog only if app has focus
if (QApplication::focusWidget() != NULL)
{
parent->blockSignals(true);
QMessageBox::warning(
parent, "Firewall Builder",
QObject::tr("Object with name '%1' already exists, "
"please choose different name.").
arg(o1->getName().c_str()),
QObject::tr("&Continue"), NULL, NULL, 0, 2 );
parent->blockSignals(false);
}
return false;
}
}