[Kwintv] crash in QtVision::SetChannel
Rizsanyi Zsolt
kwintv@mail.kde.org
Sun, 27 Oct 2002 19:10:26 +0100
On Sunday 27 October 2002 01:54, Dawit A. wrote:
> > As you maybe already know, there is a bug in QtVision::SetChannel causing
> > a crash sometimes.
>
> What do you mean sometimes ? It should only happen whenever openChannel is
> called, right ?
>
> > A backtrace showed the line 505 in qtvision.cpp to have caused the crash.
> > And indeed:
> > void QtVision::setChannel( Channel *channel )
> > {
> > if (!channel)
> > return;
> >
> > //kdDebug() << "QtVision::setChannel()" << endl;
> > ····
> > if (_chan)
> > _prevChannel = _chan->number (); // line 505
> >
> > It assumes, that if _chan is not NULL then it is a valid pointer. Which
> > is not a valid assumption, since the channels are deleted by ChannelStore
> > (and in my case they were deleted by openChannelFile)
>
> Well actually this is not a bug in ::setChannel. Though it shows up at
> this point. It is rather a bug in ::openChannelFile (const QString&) where
> _cs->clear() is called without the local pointer to a Channel object being
> reset. This, as you ponited out, leaves a dangling pointer to a channel
> object. But all the code in QtVision assumes on proper intialization of
> _cs. It just happens that none of them are currently called before
> setChannel is.
You are right. But I dont think that openChannelFile is/will be the only case
when this problem manifests itself.
> > I see some possible solutions to this:
> > 1) remove this previous channel thing - it is only used for dcop if I
> > understand it correctly, and I dont see for what it is good for
>
> No, do not do that. It is very simple to fix this problem. FWIW, the
> _prevChannel is a feature that allows you to go back to the previous
> channel by pressing one configurable shortcut key. By default this is
> Key_L. This is the same feature available on many TV sets/Remote
> controls as go back, Last, recall, previous etc...
I did not know about that feature.
> > 3) take care to do '_chan = NULL' when the channel store is deleted (or
> > that exact channel is deleted) -- this may be impossible
>
> And why is this impossible ? Channel is a QObject. All one has to do is
> connect to its destroyed signal and reset the local pointer accordingly.
I'm not that proficient in Qt programming yet... :)
> Actually, there isn't even a need for that right now even though it is the
> most proper fix. The easiest thing to do for the current situtation would
> be to simply null out the _ch pointer whenever _cs->clear() is called.
Hmm. I have not checked the code, but what happens when you delete a channel
is channel editor. Is then the _chan reset ?
I remember a crash when you opened the configure dialog, and exited with
Cancel. And I think that it came from a similar problem...
I sad that the fixing could be impossible, because I tought, that handling all
the cases is not trivial. (of course if not using destroyed signal thing :)
> > I vote for solution 1)
> >
> > What do you vote for? :)
>
> I vote for item #4. Let Dawit fix it since he caused the problem to begin
> with. :)
Okay. Just then you should fix all the problems coming from this issue :)
Regards
Zsolt