From b219b24f587877d41d5a371585acdf63d994e2c0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 16 Sep 2011 17:04:31 +0200 Subject: Get sure mainWindow() exists before trying applying settings BUG: 272107 --- src/adblock/adblockmanager.h | 4 ++-- src/application.cpp | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h index 1736b2f3..216764eb 100644 --- a/src/adblock/adblockmanager.h +++ b/src/adblock/adblockmanager.h @@ -64,7 +64,7 @@ // There are 3 kind of filter options: // // --- ### TYPE OPTIONS -// +// // You can also specify a number of options to modify the behavior of a filter. // You list these options separated with commas after a dollar sign ($) at the end of the filter // @@ -87,7 +87,7 @@ // // // --- ### INVERSE TYPE OPTIONS -// +// // Inverse type options are allowed through the ~ sign, for example: // // RULE=*/ads/*~$script,match-case diff --git a/src/application.cpp b/src/application.cpp index 2d8cddb2..627536da 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -545,16 +545,19 @@ void Application::updateConfiguration() // compute font size // (I have to admit I know nothing about these DPI questions..: copied from kwebkitpart, as someone suggested) // font size in pixels = font size in inches × screen dpi - int defaultFontSize = ReKonfig::defaultFontSize(); - int minimumFontSize = ReKonfig::minFontSize(); + if (mainWindow() && mainWindow()->currentTab()) + { + int logDpiY = mainWindow()->currentTab()->view()->logicalDpiY(); + float toPix = (logDpiY < 96.0) + ? 96.0 / 72.0 + : logDpiY / 72.0 ; - int logDpiY = mainWindow()->currentTab()->view()->logicalDpiY(); - float toPix = (logDpiY < 96.0) - ? 96.0 / 72.0 - : logDpiY / 72.0 ; + int defaultFontSize = ReKonfig::defaultFontSize(); + int minimumFontSize = ReKonfig::minFontSize(); - defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix)); - defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix)); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix)); + defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix)); + } // encodings QString enc = ReKonfig::defaultEncoding(); @@ -599,6 +602,12 @@ void Application::updateConfiguration() // ====== load Settings on main classes historyManager()->loadSettings(); + + defaultSettings = 0; + + if (!mainWindow()) + return; + if (!ReKonfig::useFavicon()) mainWindow()->setWindowIcon(KIcon("rekonq")); else @@ -634,7 +643,6 @@ void Application::updateConfiguration() break; } - defaultSettings = 0; } -- cgit v1.2.1