Move a connect in SqlTextEdit to avoid unnecessary slot calls

Move the connect for updating the line number area width from the reload
settings method to the constructor to make sure it's only called once.
Otherwise there would be more and more unnecessary connections made
whenever the settings are reloaded.
This commit is contained in:
Martin Kleusberg
2015-12-22 18:19:55 +01:00
parent 3376bd9353
commit 0fed833e55
2 changed files with 5 additions and 3 deletions

View File

@@ -101,7 +101,7 @@ void MainWindow::init()
ui->actionExecuteSql->setShortcuts(shortcuts);
QShortcut* shortcutBrowseRefresh = new QShortcut(QKeySequence("Ctrl+R"), this);
QObject::connect(shortcutBrowseRefresh, SIGNAL(activated()), ui->buttonRefresh, SLOT(click()));
connect(shortcutBrowseRefresh, SIGNAL(activated()), ui->buttonRefresh, SLOT(click()));
// Create the actions for the recently opened dbs list
for(int i = 0; i < MaxRecentFiles; ++i) {
@@ -214,7 +214,7 @@ void MainWindow::init()
{
// Check for a new release version, usually only enabled on windows
m_NetworkManager = new QNetworkAccessManager(this);
QObject::connect(m_NetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(httpresponse(QNetworkReply*)));
connect(m_NetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(httpresponse(QNetworkReply*)));
QUrl url("https://raw.githubusercontent.com/sqlitebrowser/sqlitebrowser/master/currentrelease");
m_NetworkManager->get(QNetworkRequest(url));

View File

@@ -50,6 +50,9 @@ SqlTextEdit::SqlTextEdit(QWidget* parent) :
// Do rest of initialisation
reloadSettings();
// Connect signals
connect(this, SIGNAL(linesChanged()), this, SLOT(updateLineNumberAreaWidth()));
}
SqlTextEdit::~SqlTextEdit()
@@ -132,7 +135,6 @@ void SqlTextEdit::reloadSettings()
setMarginsFont(marginsfont);
setMarginLineNumbers(0, true);
setMarginsBackgroundColor(Qt::lightGray);
connect(this, SIGNAL(linesChanged()), this, SLOT(updateLineNumberAreaWidth()));
updateLineNumberAreaWidth();
// Highlight current line