Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Getting a "QFont::setPixelSize: Pixel size <= 0 (0)" Warning Message #485

Closed
cameronkendall opened this issue Mar 8, 2013 · 30 comments
Closed

Comments

@cameronkendall
Copy link

When running tests I get the following warning message:

QFont::setPixelSize: Pixel size <= 0 (0)

Is there a way to hide/suppress this? I don't even know what it represents, and Its showing up every time I run the tests.

I'm using QT 4.8.4 on Mac OS 10.7.5

Gemfile:

group :development do
  gem 'guard-minitest', '0.5.0'
  gem 'rb-fsevent', '0.9.3'
  gem 'growl', '1.0.3'
  gem 'launchy'
  gem 'capybara-webkit', '0.14.2'
end

group :test do
  gem 'minitest', '4.6.2'
  gem 'capybara', '2.0.2'
  gem 'database_cleaner', '0.9.1'
  gem 'factory_girl_rails', '4.2.1'
end
@jferris
Copy link
Contributor

jferris commented Mar 8, 2013

There was some discussion about this on the mailing list that fizzled out: https://groups.google.com/forum/?fromgroups=#!topic/capybara-webkit/n1xMK0HnMWo

I think it's an issue in Qt and we could silence it by filtering debug output with qInstallMsgHandler.

@aminariana
Copy link

I get the same warning. Not the slightest hint about what it means.

@jaredbeck
Copy link

I get the same warning (and others) with an old capybara-webkit, testunit, and ruby 1.8.7, which seems to support @jferris suggestion that "it's an issue in Qt".

$ bundle exec rake test:integration
Started
.......QFont::setPixelSize: Pixel size <= 0 (0)
libpng warning: Unknown iTXt compression type or method
content-type missing in HTTP POST, defaulting to application/x-www-form-urlencoded. Use QNetworkRequest::setHeader() to fix this problem.
....................
Finished

$ ruby --version
ruby 1.8.7 (2012-10-12 patchlevel 371) [i686-darwin12.2.0]
$ grep capy Gemfile.lock 
  remote: git://github.com/thoughtbot/capybara-webkit.git
    capybara-webkit (0.13.0)
      capybara (>= 1.0.0, < 1.2)
    capybara (1.1.4)
  capybara (~> 1.1)
  capybara-webkit!

@petRUShka
Copy link
Contributor

I have several types of warnings:

  1. QFont::setPixelSize: Pixel size <= 0 (0)
  2. content-type missing in HTTP POST, defaulting to application/x-www-form-urlencoded. Use QNetworkRequest::setHeader() to fix this problem.

@santry
Copy link

santry commented Apr 16, 2013

@petRUShka regarding the content-type error see rails/jquery-ujs#301

@petRUShka
Copy link
Contributor

@santry, thanks for noticing that. What about first type of warnings?

@bundacia
Copy link

+1. I'm getting these same "QFont::setPixelSize: Pixel size <= 0 (0)" warnings as well.

@mcmire
Copy link

mcmire commented May 7, 2013

Here is the issue in the Qt JIRA. This issue seems to have been closed and fixed in QtWebkit instead. But that happened a couple years ago (after Qt 4.8.0 but before 4.8.4 which is the current 4.8.x release). It also appears that Qt 4.8.x might be using QtWebkit 4.9.4. Now whether or not 4.9.4 includes this bugfix, I don't know, but I would suspect at this point it does. So this is strange...

@ksweetie
Copy link

It seems to have been fixed in QtWebkit more recently too...

@jaredbeck
Copy link

Does capybara-webkit constrain the QtWebkit version at all? There is no such constraint in the .gemspec. I have no idea how dependencies are managed in C++. All I see is an #include <QtWebKit>. There is also a QTWEBKIT_VERSION_STR but I'm not seeing it used in any conditionals.

@mhoran
Copy link
Collaborator

mhoran commented May 29, 2013

@jaredbeck, see #529.

@jaredbeck
Copy link

It looks like PR #529 includes a preprocessor directive that constrains Qt >= 4.8.0. So it seems that a constraint is possible. However, I think it's safe to assume we don't want to constrain Qt just to fix a warning message, however annoying. Therefore, I think we can close this issue and recommend that people update their Qt?

@rebelwarrior
Copy link

I installed QT this past weekend through homebrew on a OSX 10.6.8 and I get the same error.

@Linuus
Copy link

Linuus commented Jul 1, 2013

I installed qt today through homebrew and also get the same message. On OSX Lion.

@stefanhendriks
Copy link

Same error here with QT 4.8.4 on OSX 10.8.4. The warning message is pretty large, so I am supressing it now in my tests although I'd prefer to have no warning at all.

@joshuaswilcox
Copy link

@stefanhendriks how did you suppress this in your tests? Thanks!

@pbrisbin
Copy link

FYI: Arch just got qt5-webkit 5.1 and the messages are no longer appearing.

@stefanhendriks
Copy link

@joshuaswilcox we basically have a class that overrides a method that writes messages. We collect them and print them after all tests are ran (we run dump_warnings ourselves at the end). Here some code:

FYI, what i did was basically cut off the warning (in dump_warnings) at 255 characters orso.

class WarningSuppressor

        SUPPRESS_THESE_WARNINGS = [
            'QFont::setPixelSize: Pixel size <= 0 (0)',
            'content-type missing in HTTP POST, defaulting to'
        ]

        class << self
          def write(message)
            if suppress_warning? message
              0
            else
              @warnings ||= []
              @warnings << message
              message.length
            end
          end

          def dump_warnings
            if @warnings
              puts
              puts "Warnings from QT while running specs:"

              @warnings.each do |warning|
                puts warning
              end
            end
          end

          private

          def suppress_warning? message
            SUPPRESS_THESE_WARNINGS.any? { |suppressable_warning| message.try(:strip).try(:include?, suppressable_warning) }
          end
        end
      end

      Capybara.register_driver :webkit do |app|
        Capybara::Webkit::Driver.new(app, stderr: WarningSuppressor)
      end

@Fjan
Copy link

Fjan commented Jul 25, 2013

@stefanhendriks Thanks! that warning has been bugging me for months. I didn't know realise was that easy to filter. Simply erasing it from the output stream is good enough for me though.

class WarningSuppressor
  class << self
    def write(message)
      puts(message) unless message =~ /QFont::setPixelSize: Pixel size <= 0/
      0
    end
  end
end

@joshuaswilcox
Copy link

@stefanhendriks and @Fjan, sorry for the naivety, but where did you put your custom class?

@Fjan
Copy link

Fjan commented Jul 25, 2013

@joshuaswilcox Doesn't really matter, you would probably put it in the same file where you use it, typically test_helper.rb

@joshuaswilcox
Copy link

@Fjan perfect, thanks!

@joshuaswilcox
Copy link

@Fjan sorry to be a bother, but I added this to a test_helper.rb and required it in my controller_name_spec.rb, but it still prints out. Not sure what I am missing? Thanks very much

@joshuaswilcox
Copy link

@Fjan yeah here is my spec_helper.rb

Capybara.default_driver = :webkit
Capybara.javascript_driver = :webkit
Capybara.default_wait_time = 5
Capybara.register_driver :webkit do |app|
  Capybara::Webkit::Driver.new(app, stderr: WarningSuppressor)
end

@Fjan
Copy link

Fjan commented Jul 25, 2013

@joshuaswilcox Sorry, I don't know. This is not a good place for general Ruby questions, please try stack overflow

@rebelwarrior
Copy link

@Fjan shouldn't that if be an unless? When I run it w/ the if I get the error displayed still.

@Fjan
Copy link

Fjan commented Jul 25, 2013

@rebelwarrior @joshuaswilcox You're right! I modified a line to remove some stuff that wasn't relevant here and I ended up reversing the condition. Sorry about that.
(PS. fixed the original snippet to avoid confusing other people)

@joshuaswilcox
Copy link

Bingo, Thought I was going crazy. Thanks all. @Fjan @rebelwarrior

@mhoran
Copy link
Collaborator

mhoran commented Jul 2, 2014

Closing this out. We've done just about all we can in capybara-webkit to silence these issues. Anyone who is still experiencing issues should:

  1. Update Qt to the latest version (currently 5.3).
  2. Ensure that they have not installed a debug version or compiled with the debug option.

@EXboys
Copy link

EXboys commented Nov 22, 2016

I use Pyqt and who who has solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests