Closed Bug 854115 Opened 8 years ago Closed 8 years ago

nsWidgetFactory.cpp compile error: static_cast from 'nsIContent *' to 'nsISupports *' is not allowed

Categories

(Core :: Widget: Gtk, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: mats, Assigned: jfkthame)

References

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

My mozilla-inbound (rev bf15d22f0bd2) debug build on Linux64 fails to build:

clang++ [snip]  widget/gtk2/nsWidgetFactory.cpp
In file included from widget/gtk2/nsWidgetFactory.cpp:8:
In file included from ../../dist/include/mozilla/ModuleUtils.h:10:
In file included from ../../dist/include/mozilla/Module.h:12:
../../dist/include/nsCOMPtr.h:492:11: error: static_cast from 'nsIContent *' to 'nsISupports *' is not allowed
          NSCAP_LOG_RELEASE(this, mRawPtr);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../dist/include/nsTraceRefcnt.h:47:31: note: expanded from macro 'NSCAP_LOG_RELEASE'
    NS_LogCOMPtrRelease((_c), static_cast<nsISupports*>(_p))
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../dist/include/nsTArray.h:439:9: note: in instantiation of member function 'nsCOMPtr<nsIContent>::~nsCOMPtr' requested here
    e->~E();
        ^
../../dist/include/nsTArray.h:1304:20: note: in instantiation of member function 'nsTArrayElementTraits<nsCOMPtr<nsIContent> >::Destruct' requested here
      elem_traits::Destruct(iter);
                   ^
../../dist/include/nsTArray.h:1023:5: note: in instantiation of member function 'nsTArray_Impl<nsCOMPtr<nsIContent>, nsTArrayInfallibleAllocator>::DestructRange' requested here
    DestructRange(start, count);
    ^
../../dist/include/nsTArray.h:1034:5: note: in instantiation of member function 'nsTArray_Impl<nsCOMPtr<nsIContent>, nsTArrayInfallibleAllocator>::RemoveElementsAt' requested here
    RemoveElementsAt(0, Length());
    ^
../../dist/include/nsTArray.h:519:22: note: in instantiation of member function 'nsTArray_Impl<nsCOMPtr<nsIContent>, nsTArrayInfallibleAllocator>::Clear' requested here
  ~nsTArray_Impl() { Clear(); }
                     ^
../../dist/include/nsTArray.h:1377:7: note: in instantiation of member function 'nsTArray_Impl<nsCOMPtr<nsIContent>, nsTArrayInfallibleAllocator>::~nsTArray_Impl' requested here
class nsTArray : public nsTArray_Impl<E, nsTArrayInfallibleAllocator>
      ^
In file included from widget/gtk2/nsWidgetFactory.cpp:8:
In file included from ../../dist/include/mozilla/ModuleUtils.h:10:
In file included from ../../dist/include/mozilla/Module.h:12:
../../dist/include/nsCOMPtr.h:494:13: error: member access into incomplete type 'nsIContent'
            NSCAP_RELEASE(this, mRawPtr);
            ^
../../dist/include/nsCOMPtr.h:110:44: note: expanded from macro 'NSCAP_RELEASE'
  #define NSCAP_RELEASE(this, ptr)    (ptr)->Release()
                                           ^
../../dist/include/nsITheme.h:25:7: note: forward declaration of 'nsIContent'
class nsIContent;
      ^
2 errors generated.
make[2]: *** [nsWidgetFactory.o] Error 1

=============================================

# clang++ --version
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
I'm guessing this is a regression from bug 847007.
Blocks: 847007
Keywords: regression
I ran into a similar failure on my windows build. AFAICS, this should fix things for both the gtk2 and windows cases; there might still be other platforms that will run into this, though.
Attachment #729038 - Flags: review?(Ms2ger)
Assignee: nobody → jfkthame
Attachment #729038 - Flags: review?(Ms2ger) → review+
Thanks for the quick review, but on second thought, I don't think that's the right patch. The problem arises because of the autoarray of nsCOMPtrs that is declared in nsNativeTheme.h, so we should put the #include of nsIContent.h there as well instead of forward-declaring the class and relying on other source files to do the 'right' thing.
Attachment #729048 - Flags: review?(Ms2ger)
Comment on attachment 729048 [details] [diff] [review]
add #include "nsIContent.h" to nsNativeTheme.h because of the use of nsAutoTArray<nsCOMPtr<nsIContent>... there

Review of attachment 729048 [details] [diff] [review]:
-----------------------------------------------------------------

Absolutely.
Attachment #729048 - Flags: review?(Ms2ger) → review+
Attachment #729038 - Attachment is obsolete: true
Keywords: checkin-needed
Duplicate of this bug: 854507
This also breaks Thunderbird build, but the patch fixes it. Please check in soon.
https://hg.mozilla.org/mozilla-central/rev/6fb86648b394
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.