Opened 9 years ago

Closed 8 years ago

#4903 closed Enhancement (invalid)

Ability to disable dbus support in Qt client

Reported by: nzqr Owned by:
Priority: Normal Milestone: None Set
Component: Qt Client Version: 2.52
Severity: Normal Keywords: patch_needed
Cc:

Description

Here's sample patch:

  • app.cc

     
    1414#include <ctime>
    1515#include <iostream>
    1616
     17#ifdef MY_DBUS
    1718#include <QDBusConnection>
    1819#include <QDBusConnectionInterface>
    1920#include <QDBusError>
    2021#include <QDBusMessage>
     22#endif
     23
    2124#include <QDialogButtonBox>
    2225#include <QIcon>
    2326#include <QLabel>
     
    3235
    3336#include "add-data.h"
    3437#include "app.h"
     38
     39#ifdef MY_DBUS
    3540#include "dbus-adaptor.h"
     41#endif
     42
    3643#include "formatter.h"
    3744#include "mainwin.h"
    3845#include "options.h"
     
    4552
    4653namespace
    4754{
     55#ifdef MY_DBUS
    4856    const QString DBUS_SERVICE     = QString::fromAscii( "com.transmissionbt.Transmission"  );
    4957    const QString DBUS_OBJECT_PATH = QString::fromAscii( "/com/transmissionbt/Transmission" );
    5058    const QString DBUS_INTERFACE   = QString::fromAscii( "com.transmissionbt.Transmission"  );
    51 
     59#endif
     60               
    5261    const char * MY_READABLE_NAME( "transmission-qt" );
    5362
    5463    const tr_option opts[] =
     
    245254        addTorrent( *it );
    246255
    247256    // register as the dbus handler for Transmission
     257#ifdef MY_DBUS
    248258    new TrDBusAdaptor( this );
    249259    QDBusConnection bus = QDBusConnection::sessionBus();
    250260    if( !bus.registerService( DBUS_SERVICE ) )
    251261        std::cerr << "couldn't register " << qPrintable(DBUS_SERVICE) << std::endl;
    252262    if( !bus.registerObject( DBUS_OBJECT_PATH, this ) )
    253263        std::cerr << "couldn't register " << qPrintable(DBUS_OBJECT_PATH) << std::endl;
     264#endif
    254265}
    255266
    256267/* these functions are for popping up desktop notifications */
     
    282293
    283294    if( tor && !tor->name().isEmpty() )
    284295    {
     296#ifdef MY_DBUS
    285297        notify( tr( "Torrent Completed" ), tor->name( ) );
     298#endif
    286299
    287300        disconnect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) );
    288301    }
     
    295308
    296309    if( tor && !tor->name().isEmpty() )
    297310    {
     311#ifdef MY_DBUS
    298312        const int age_secs = tor->dateAdded().secsTo(QDateTime::currentDateTime());
    299313        if( age_secs < 30 )
    300314            notify( tr( "Torrent Added" ), tor->name( ) );
     315#endif
    301316
    302317        disconnect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onNewTorrentChanged(int)) );
    303318
     
    439454    QApplication :: alert ( myWindow );
    440455}
    441456
     457#ifdef MY_DBUS
    442458bool
    443459MyApp :: notify( const QString& title, const QString& body ) const
    444460{
     
    462478    //std::cerr << qPrintable(replyMsg.errorMessage()) << std::endl;
    463479    return (replyMsg.type() == QDBusMessage::ReplyMessage) && !replyMsg.arguments().isEmpty();
    464480}
     481#endif
    465482
    466483/***
    467484****
     
    481498
    482499    // try to delegate the work to an existing copy of Transmission
    483500    // before starting ourselves...
     501#ifdef MY_DBUS
    484502    bool delegated = false;
    485503    QDBusConnection bus = QDBusConnection::sessionBus();
    486504    for( int i=0, n=addme.size(); i<n; ++i )
     
    509527
    510528    if( delegated )
    511529        return 0;
     530#endif
    512531
    513532    tr_optind = 1;
    514533    MyApp app( argc, argv );

Attachments (1)

my_qtr_dbus.patch (4.3 KB) - added by nzqr 9 years ago.
for transmission 2.52

Download all attachments as: .zip

Change History (12)

comment:1 Changed 9 years ago by jordan

What is the use case for this?

comment:2 Changed 9 years ago by nzqr

To conserve ram on older machines, while still using gui.

comment:3 Changed 9 years ago by jordan

How much memory is saved by disabling DBus support?

comment:4 Changed 9 years ago by nzqr

This will vary based on achitecture and compiler options, and every little bit helps. If this is not enough for substantiation, when compiling why do i bother to build dbus when it's not needed for me?

comment:5 Changed 9 years ago by jordan

Top says stock transmission-qt uses 39m RES / 29m SHR.

Top says patched transmission-qt uses 39m RES / 29m SHR.

This patch doesn't seem to save any memory on i686...

comment:6 Changed 9 years ago by jordan

  • Resolution set to worksforme
  • Status changed from new to closed

comment:7 follow-up: Changed 9 years ago by nzqr

  • Component changed from Transmission to Qt Client
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from 2.51 to 2.52

Seems that you done something wrong, for example qtdbus still is linked, thats my results of

ps -o rss,comm `pgrep 'transmission-qt|dbus'`

without patch:

  RSS COMMAND
34452 transmission-qt
  724 dbus-launch
  668 dbus-daemon

with:

  RSS COMMAND
33836 transmission-qt

dbus session daemon included because no other app than transmission uses it on my system.

Btw, what's about porting on windows, has dbus on windows any sense?

comment:8 Changed 9 years ago by jordan

  • Keywords patch_needed added
  • Resolution set to worksforme
  • Status changed from reopened to closed

Thanks for providing some numbers.

So, this is a pretty limited win that few people will notice. I don't care about this ticket, but if it's important enough to you that you'll finish the patch to handle the qmake plumbing and make a patchfile of the unified diffs, then please reopen this ticket and attach the patchfile.

comment:9 in reply to: ↑ 7 Changed 9 years ago by rb07

Replying to nzqr:

Btw, what's about porting on windows, has dbus on windows any sense?

I don't understand why you ask this, but the answer is yes, transmission-qt uses dbus-daemon to implement the file and magnet association (just like it does in Linux).

Perhaps your question is more about dbus on Windows, you probably think it doesn't work there, it does, or that is not used by anyone, is being used by the "KDE on Windows Initiative", and Emacs, and others.

Changed 9 years ago by nzqr

for transmission 2.52

comment:10 Changed 9 years ago by nzqr

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I have attached the patch, hope it will do.

comment:11 Changed 8 years ago by jordan

  • Resolution set to invalid
  • Status changed from reopened to closed

I still don't like this ticket because the benefits seem very minimal and difficult to reach -- how many people are going to compile their own version of transmission-qt to disable DBus support?

Note: See TracTickets for help on using tickets.